DEM Downloader Module
Download SRTM Digital Elevation Model data for specified geographic areas.
This module provides functions to download SRTM elevation data using either bounding box coordinates or place names, via NASA Earthdata authentication.
SRTM Data
Source: NASA Shuttle Radar Topography Mission
Coverage: 60N to 56S latitude
Resolution: 1 arc-second (~30m) for SRTM1, 3 arc-second (~90m) for SRTM3
Format: HGT (Height) files, 1 x 1 tile grid
Usage Examples
Download by bounding box:
from src.terrain.dem_downloader import download_dem_by_bbox
bbox = (42.0, -83.5, 42.5, -83.0) # Detroit area
files = download_dem_by_bbox(
bbox=bbox,
output_dir="data/detroit_dem",
)
Download by place name:
from src.terrain.dem_downloader import download_dem_by_place_name
files = download_dem_by_place_name(
place_name="Detroit, MI",
output_dir="data/detroit_dem",
)
API Reference
DEM (Digital Elevation Model) downloader for SRTM elevation data.
This module provides functions to download SRTM elevation data for specified geographic areas using either bounding box coordinates or place names.
- SRTM Data:
NASA Shuttle Radar Topography Mission
Global coverage (60°N to 56°S)
1 arc-second (~30m) resolution (SRTM1)
3 arc-second (~90m) resolution (SRTM3)
Data format: HGT (Height) files
Tile size: 1° × 1° geographic grid
Usage - Download by bbox:
from src.terrain.dem_downloader import download_dem_by_bbox
bbox = (42.0, -83.5, 42.5, -83.0) # Detroit area
files = download_dem_by_bbox(
bbox=bbox,
output_dir="data/detroit_dem",
username="your_earthdata_username",
password="your_earthdata_password"
)
Usage - Download by place name:
from src.terrain.dem_downloader import download_dem_by_place_name
files = download_dem_by_place_name(
place_name="Detroit, MI",
output_dir="data/detroit_dem",
username="your_earthdata_username",
password="your_earthdata_password"
)
Usage - Visualize bbox:
from src.terrain.dem_downloader import display_bbox_on_map
bbox = (42.0, -83.5, 42.5, -83.0)
display_bbox_on_map(bbox, output_file="bbox_map.html")
# Open bbox_map.html in browser to visualize the area
- src.terrain.dem_downloader.get_srtm_tile_name(lat, lon)[source]
Get SRTM tile name for a given latitude/longitude coordinate.
SRTM tiles are 1°×1° and named by their southwest corner coordinates.
- Parameters:
- Returns:
Tile name following SRTM convention (e.g., “N42W084”)
- Return type:
Examples
>>> get_srtm_tile_name(42.3, -83.0) 'N42W083' >>> get_srtm_tile_name(42.9, -83.9) 'N42W084'
- src.terrain.dem_downloader.calculate_required_srtm_tiles(bbox)[source]
Calculate which SRTM tiles are needed to cover a bounding box.
- Parameters:
bbox (Tuple[float, float, float, float]) – Bounding box as (south, west, north, east) in decimal degrees
- Returns:
List of SRTM tile names (e.g., [“N42W084”, “N42W083”])
- Return type:
Examples
>>> calculate_required_srtm_tiles((42.0, -83.5, 42.5, -83.0)) ['N42W084', 'N42W083']
- src.terrain.dem_downloader.download_dem_by_bbox(bbox, output_dir, username=None, password=None)[source]
Download SRTM elevation data for a bounding box area.
- Parameters:
bbox (Tuple[float, float, float, float]) – Bounding box as (south, west, north, east) in decimal degrees
output_dir (str) – Directory to save downloaded DEM files
username (str | None) – NASA Earthdata username (optional for testing)
password (str | None) – NASA Earthdata password (optional for testing)
- Returns:
List of Path objects pointing to downloaded ZIP files
- Return type:
Note
NASADEM downloads tiles as ZIP files (e.g., “NASADEM_HGT_N32W117.zip”). Each ZIP contains the HGT file and metadata.
Examples
>>> bbox = (42.0, -83.5, 42.5, -83.0) # Detroit >>> files = download_dem_by_bbox(bbox, "data/dem", "user", "pass") >>> print(f"Downloaded {len(files)} tiles")
- src.terrain.dem_downloader.download_dem_by_place_name(place_name, output_dir, username=None, password=None)[source]
Download SRTM elevation data for a named location.
- Parameters:
- Returns:
List of Path objects pointing to downloaded HGT files
- Return type:
Examples
>>> files = download_dem_by_place_name("Detroit, MI", "data/dem")
- src.terrain.dem_downloader.display_bbox_on_map(bbox, output_file='bbox_map.html')[source]
Create an interactive HTML map showing the bounding box.
Helps users visualize and verify their bounding box selection.
- Parameters:
- Return type:
None
Examples
>>> bbox = (42.0, -83.5, 42.5, -83.0) >>> display_bbox_on_map(bbox, "detroit_bbox.html") # Opens detroit_bbox.html in browser
See Also
Data Loading Module - Loading downloaded DEM files
Core Module - Terrain class for working with DEM data