Add USGS 3DEP as a new DEM data source#24
Merged
scottstanie merged 11 commits intomasterfrom Feb 16, 2026
Merged
Conversation
The NISAR DEM is a Copernicus-derived DEM prepared by JPL for the NISAR mission with EGM2008-to-WGS84 conversion pre-applied and ocean gaps filled. It is accessed via a hierarchical VRT and requires NASA Earthdata credentials for authentication. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add support for downloading elevation data from the USGS 3D Elevation Program (3DEP), which provides high-resolution LiDAR-derived DEMs (up to 1m) across the US. Data is fetched via the 3DEP ImageServer exportImage REST endpoint using requests (no new dependencies). Large areas are automatically chunked into manageable tiles. Vertical datum conversion from NAVD88 to WGS84 ellipsoidal heights uses GDAL (same optional dep as COP). Usage: sardem --bbox -105.1 40.0 -105.0 40.1 --data-source 3DEP https://claude.ai/code/session_013H2JBDQ3gKG8JgdeDUiAi6
…s to source pixel grid When gdal.Warp is called with integer-degree outputBounds (e.g. -104,31,-103,32), the output pixel centers land exactly on the boundary between two source pixels. Nearest-neighbour resampling must break a tie, and the result depends on floating-point rounding of the source VRT origin. The COP and NISAR global VRTs have different origins (-179 vs -180 degrees), causing the rounding to go opposite ways -- COP picks source pixel N while NISAR picks N+1, producing a systematic 1-pixel shift in both X and Y (up to 25m elevation error). The fix snaps outputBounds outward to the nearest source pixel *edge* via utils.align_bounds_to_pixel_grid(). This makes output pixel centers coincide with source pixel centers, so the warp becomes a pure pixel copy -- bit-for-bit identical to reading the raw tiles. The function is idempotent: bounds already on pixel edges pass through unchanged. Result: COP vs NISAR |max| drops from 25.1m to 0.008m (sub-cm, limited by the difference between GDAL's and JPL's EGM2008-to-WGS84 conversion). For a 1-degree integer bbox the output grows from 3600x3600 to 3601x3601 to include boundary pixels. Also adds debug_pixel_shift.py which demonstrates the issue and validates the fix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for downloading elevation data from the USGS 3D Elevation
Program (3DEP), which provides high-resolution LiDAR-derived DEMs
(up to 1m) across the US.
Data is fetched via the 3DEP ImageServer exportImage REST endpoint
using requests (no new dependencies). Large areas are automatically
chunked into manageable tiles. Vertical datum conversion from NAVD88
to WGS84 ellipsoidal heights uses GDAL (same optional dep as COP).
Usage: sardem --bbox -105.1 40.0 -105.0 40.1 --data-source 3DEP
https://claude.ai/code/session_013H2JBDQ3gKG8JgdeDUiAi6