Shuttle Radar Topography Mission (SRTM) Digital Elevation Model (DEM) search and download utility
Project description
NASADEM - Digital Elevation Model (DEM) Access Utility
This Python package provides utilities for accessing and downloading Digital Elevation Model (DEM) data from the NASADEM dataset, which is a reprocessed version of the Shuttle Radar Topography Mission (SRTM) data.
Version 2.0.0 modernizes the package to use NASA's official earthaccess library for reliable and efficient data access from NASA's Earthdata Cloud.
Gregory H. Halverson (they/them)
gregory.h.halverson@jpl.nasa.gov
NASA Jet Propulsion Laboratory 329G
What's New in v2.0.0
- 🚀 Modern Data Access: Uses NASA's official
earthaccesspackage - ✅ Reliable Downloads: Built-in retry logic and error handling
- ☁️ Cloud-Optimized: Direct access to NASA Earthdata Cloud
- 🔐 Simplified Authentication: Multiple authentication options (
.netrc, environment variables, interactive) - 🗑️ Removed Legacy Code: Deprecated old LP DAAC connection methods
Installation
pip install NASADEM
Or install from source:
git clone https://github.com/gregory-halverson/NASADEM.git
cd NASADEM
pip install -e .
Prerequisites
You need a NASA Earthdata account to download NASADEM data.
Authentication
There are several ways to authenticate:
Option 1: Interactive Login (Recommended for first-time users)
import earthaccess
earthaccess.login() # Will prompt for credentials and optionally save them
Option 2: .netrc File
Create a ~/.netrc file with your credentials:
machine urs.earthdata.nasa.gov
login YOUR_USERNAME
password YOUR_PASSWORD
Then set proper permissions:
chmod 600 ~/.netrc
Option 3: Environment Variables
export EARTHDATA_USERNAME=your_username
export EARTHDATA_PASSWORD=your_password
Option 4: Direct Credentials
from NASADEM import NASADEMConnection
nasadem = NASADEMConnection(
username="your_username",
password="your_password",
persist_credentials=True # Optionally save to .netrc
)
Usage
Basic Usage with Default Instance
from NASADEM import NASADEM
from rasters import RasterGrid
# Define target area
geometry = RasterGrid.from_bbox(
xmin=-118.5, ymin=33.5, xmax=-117.5, ymax=34.5,
cell_size=30, crs="EPSG:4326"
)
# Get elevation data
elevation = NASADEM.elevation_m(geometry)
print(f"Elevation range: {elevation.min():.1f} to {elevation.max():.1f} meters")
# Get surface water body mask
water = NASADEM.swb(geometry)
Custom Connection
from NASADEM import NASADEMConnection
# Create connection with custom download directory
nasadem = NASADEMConnection(
download_directory="~/my_nasadem_data"
)
# Use it the same way
elevation = nasadem.elevation_m(geometry)
Point Extraction
from rasters import Point, MultiPoint
from NASADEM import NASADEM
# Single point
point = Point(-118.0, 34.0)
elevation = NASADEM.elevation_m(point)
print(f"Elevation at point: {elevation:.1f} m")
# Multiple points
points = MultiPoint([
Point(-118.0, 34.0),
Point(-117.5, 33.8),
Point(-118.2, 34.2)
])
elevations = NASADEM.elevation_m(points)
print(f"Elevations: {elevations}")
Working with Tiles
from NASADEM import NASADEM
# Get tiles covering an area
tiles = NASADEM.tiles(geometry)
print(f"Tiles needed: {tiles}")
# Download a specific tile
granule = NASADEM.download_tile("n34w118")
elevation = granule.elevation_m
swb = granule.swb
API Reference
NASADEMConnection
Main class for accessing NASADEM data.
Methods:
elevation_m(geometry): Get elevation in meterselevation_km(geometry): Get elevation in kilometersswb(geometry): Get surface water body maskdownload_tile(tile): Download a specific tiletiles(geometry): Get list of tiles covering a geometry
Parameters:
username(str, optional): NASA Earthdata usernamepassword(str, optional): NASA Earthdata passwordworking_directory(str, optional): Working directory for temporary filesdownload_directory(str, optional): Directory for downloaded tiles (default:~/data/NASADEM)persist_credentials(bool, optional): Save credentials to.netrc(default: False)skip_auth(bool, optional): Skip authentication (useful for testing, default: False)
NASADEMGranule
Represents a single NASADEM tile.
Properties:
elevation_m: Elevation raster in metersswb: Surface water body maskgeometry: Raster geometry of the tiletile: Tile identifier (e.g., "n34w118")
Data Description
NASADEM provides:
- Elevation data: 1 arc-second (~30m) resolution global coverage (60°N to 56°S)
- Surface water body mask: Boolean mask of water bodies
- Void-filled: Improved version of SRTM with fewer data voids
- Accuracy: Vertical accuracy typically better than 16m (absolute), 10m (relative)
Tile Naming Convention
Tiles are named using latitude/longitude: {n|s}XX{e|w}XXX
Examples:
n34w118: 34°N to 35°N, 118°W to 117°W (Los Angeles area)s10e142: 10°S to 9°S, 142°E to 143°E (Northern Australia)
Migration from v1.x
If you're upgrading from v1.x:
- Authentication: Update to use
earthaccessauthentication methods - No more URL construction: The package now handles data discovery automatically
- Deprecated:
LPDAACDataPoolclass is no longer used - Same API: The main
elevation_m(),elevation_km(), andswb()methods work the same
Old code (v1.x):
from NASADEM import NASADEMConnection
nasadem = NASADEMConnection(
username="user",
password="pass",
remote="https://e4ftl01.cr.usgs.gov" # Old URL
)
New code (v2.0):
from NASADEM import NASADEMConnection
# Simpler - earthaccess handles the URLs
nasadem = NASADEMConnection(
username="user",
password="pass"
)
Troubleshooting
Authentication Issues
If you get authentication errors:
import earthaccess
earthaccess.login(persist=True) # Save credentials
Download Failures
The package automatically retries failed downloads. If problems persist:
- Check your internet connection
- Verify your NASA Earthdata credentials
- Check NASA Earthdata system status: https://status.earthdata.nasa.gov/
Tile Not Available
Some areas may not be covered by NASADEM (latitudes > 60°N or < 56°S). The error message will indicate this.
References
- NASA JPL. (2013). Shuttle Radar Topography Mission (SRTM) Digital Elevation Model (DEM). NASA Earthdata. Retrieved from https://earthdata.nasa.gov.
- Farr, T. G., Rosen, P. A., Caro, E., Crippen, R., Duren, R., Hensley, S., ... & Alsdorf, D. (2007). The Shuttle Radar Topography Mission. Reviews of Geophysics, 45(2), RG2004. https://doi.org/10.1029/2005RG000183
- NASADEM Data Product. (2020). NASA Jet Propulsion Laboratory. Retrieved from https://doi.org/10.5067/MEaSUREs/NASADEM/NASADEM_HGT.001
- earthaccess Documentation. Retrieved from https://earthaccess.readthedocs.io/
License
See LICENSE file.
Documentation
- Migration Guide - How to upgrade from v1.x to v2.0.0
- Changelog - Version history and changes
- Release Summary - Detailed v2.0.0 release notes
Contributing
Issues and pull requests are welcome at https://github.com/gregory-halverson/NASADEM
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nasadem-2.1.0.tar.gz.
File metadata
- Download URL: nasadem-2.1.0.tar.gz
- Upload date:
- Size: 619.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3a73029ef44f7b98db732e8fd04314f87781df6af90df47a86a6b3a378ff7d1
|
|
| MD5 |
a4ce1e94c1733a64dded9c23dd001650
|
|
| BLAKE2b-256 |
3ab6c9d2e2aea2e67b94a516d951f262050a76b9532f89cabf8165e414e4036f
|
File details
Details for the file nasadem-2.1.0-py3-none-any.whl.
File metadata
- Download URL: nasadem-2.1.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1091e17bfc97951afc6351bb0a37613e781496baf4188cb8eb71fd14d4378e3a
|
|
| MD5 |
7de3b63ec505c312f1829d9594ae21cf
|
|
| BLAKE2b-256 |
ae36882c877bd792762da66d6d215ac7fc9a92f3186592fc135e2605275a2ed6
|