Skip to main content

Easy retrieval of seamless DEM from 3DEP across US.

Project description

Seamless3DEP: Streamlined Access to USGS 3DEP Topographic Data

PyPi Conda Version CodeCov Python Versions Downloads

CodeFactor Ruff pre-commit Binder

Seamless3DEP is a lightweight Python package that simplifies access to topographic data from the USGS 3D Elevation Program (3DEP). Whether you need elevation data or its derivatives, Seamless3DEP provides an efficient interface to both static and dynamic 3DEP products. For global coverage or bathymetry-inclusive workflows, Seamless3DEP also exposes the NOAA global DEM mosaic and a generic helper for any ArcGIS ImageServer/exportImage endpoint.

Seamless3DEP utilizes connection pooling across threads (safely) to optimize service calls and minimize redundant connections. This reduces both the service load and the time required to retrieve data, making it an ideal tool for handling large-scale topographic data requests.

📚 Full documentation is available here.

Available Products

Static DEMs

  • 1/3 arc-second (10 meters)
  • 1 arc-second (30 meters)
  • 2 arc-second (60 meters)

Dynamic Products

  • Digital Elevation Model (DEM)
  • Hillshade Derivatives:
    • Gray Hillshade
    • Multidirectional Hillshade
    • GreyHillshade with Elevation Fill
    • Hillshade with Elevation Tint
  • Terrain Analysis:
    • Aspect (Degrees and Map)
    • Slope (Degrees and Map)
    • Height (Ellipsoidal)
  • Contours:
    • Contour 25 (Dynamically generates 25 contours for the area of interest)
    • Contour Smoothed 25 (Smoothed version of the 25 contours)

Core Functions

Seamless3DEP offers eight main functions designed for efficient data retrieval and processing:

  • get_dem: Retrieves static DEMs within a specified bounding box. The function automatically splits large areas into manageable tiles, downloads data as GeoTIFF files in EPSG:4326, and supports resolutions of 10m, 30m, or 60m. A buff_npixels option produces overlapping tiles to avoid NoData strips along seams when mosaicking with tiffs_to_da.
  • get_map: Fetches any 3DEP product (including DEMs and terrain derivatives) for areas within the US. Works with all available product types, allows custom resolution settings, and downloads in EPSG:3857. Also accepts buff_npixels for overlapping tiles.
  • get_global_dem: Fetches the NOAA global DEM mosaic (SRTM + GEBCO + ICESat) for any bounding box on Earth. Returns GeoTIFFs in EPSG:3857. Unlike 3DEP, it includes sub-zero bathymetric values (down to roughly -9982 m), making it the right choice outside the US or for coastal and marine workflows. Native resolution is approximately 30 m (1 arc-second).
  • get_image_server: General-purpose downloader for any ArcGIS ImageServer/exportImage endpoint. Accepts any output CRS, an optional Esri rendering rule, and handles URL validation, bbox tiling, and resume-on-failure automatically. get_map and get_global_dem are thin wrappers over this function.
  • elevation_bygrid: Samples elevation values from the 10 m seamless DEM at a grid of longitude/latitude coordinates. Reads directly from the USGS Cloud-Optimized GeoTIFFs (EPSG:4269) and supports configurable resampling methods including nearest, bilinear, cubic, cubic spline, and Lanczos.
  • decompose_bbox: Handles large area requests by breaking down extensive bounding boxes into optimal sizes based on resolution and maximum pixel count, ensuring efficient data retrieval.
  • build_vrt: Creates virtual raster datasets by combining multiple GeoTIFF files. Requires libgdal-core installation and supports efficient data handling for large areas. Note that libgdal-core is an optional dependency and is not installed when seamless-3dep is installed from PyPI. However, it is installed as a dependency when seamless-3dep is installed from conda-forge.
  • tiffs_to_da: Converts a list of GeoTIFF files to an xarray.DataArray object. This function is useful for combining multiple GeoTIFF files that get_map, get_dem, and get_global_dem produce into a single xarray.DataArray for further analysis. Note that shapely and rioxarray need to be installed to use this function.

Important Notes

  • Bounding box coordinates should be in decimal degrees (WGS84) format: (west, south, east, north)
  • Default projection for requesting maps is EPSG:3857
  • get_map is restricted to US coverage; use get_global_dem or get_image_server for data outside the US

Installation

Choose your preferred installation method:

Using pip

pip install seamless-3dep

Using micromamba (recommended)

micromamba install -c conda-forge seamless-3dep

Alternatively, you can use conda or mamba.

Quick Start Guide

We can retrieve topographic data using Seamless3DEP in just a few lines of code. Then, we can visualize or even reproject the data using rioxarray.

Retrieving a DEM

from pathlib import Path
import seamless_3dep as s3dep
import rioxarray as rxr

# Define area of interest (west, south, east, north)
bbox = (-105.7006276, 39.8472777, -104.869054, 40.298293)
data_dir = Path("data")

# Download DEM
tiff_files = s3dep.get_dem(bbox, data_dir)

# Convert to xarray.DataArray
dem = s3dep.tiffs_to_da(tiff_files, bbox, crs=4326)

DEM Example

Retrieving a Slope Map

slope_files = s3dep.get_map("Slope Degrees", bbox, data_dir)
dem = s3dep.tiffs_to_da(slope_files, bbox)

Slope Example

Contributing

We welcome contributions! Please see the contributing section for guidelines and instructions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seamless_3dep-0.5.1.tar.gz (2.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seamless_3dep-0.5.1-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file seamless_3dep-0.5.1.tar.gz.

File metadata

  • Download URL: seamless_3dep-0.5.1.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for seamless_3dep-0.5.1.tar.gz
Algorithm Hash digest
SHA256 672016a3d04ab6de2fa6f282cc3c781c710ed37d69cbc16dd7db61fa935c70c4
MD5 283050bb1400ab810662428dc50033b7
BLAKE2b-256 1772e22c08efada5cba071f882405338fcd70c33a7030de3051dfc71030bddd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for seamless_3dep-0.5.1.tar.gz:

Publisher: release.yml on hyriver/seamless-3dep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file seamless_3dep-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: seamless_3dep-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for seamless_3dep-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eb6daf6fa4b049b9df8172c1d90c7108a42ba5a7bf97619378e6b84e3ecedb2d
MD5 405ffe23d4a56b38f86ce5705cada624
BLAKE2b-256 99a8cc28c74166e7abdb57ceedfd8989c02938ade4408ec4253a6587ca26af3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for seamless_3dep-0.5.1-py3-none-any.whl:

Publisher: release.yml on hyriver/seamless-3dep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page