bmi-topography
Fetch and cache land elevation data from OpenTopography through an API, BMI, or CLI
Science Score: 85.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 9 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
✓Committers with academic emails
1 of 4 committers (25.0%) from academic institutions -
✓Institutional organization owner
Organization csdms has institutional domain (csdms.colorado.edu) -
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (8.2%) to scientific vocabulary
Keywords
Repository
Fetch and cache land elevation data from OpenTopography through an API, BMI, or CLI
Basic Info
- Host: GitHub
- Owner: csdms
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://bmi-topography.csdms.io
- Size: 5.19 MB
Statistics
- Stars: 11
- Watchers: 6
- Forks: 4
- Open Issues: 8
- Releases: 4
Topics
Metadata Files
README.md
bmi-topography
bmi-topography is a Python library for fetching and caching land elevation data using the OpenTopography REST API.
The bmi-topography library provides access to the following global raster datasets:
- SRTMGL3 (SRTM GL3 90m)
- SRTMGL1 (SRTM GL1 30m)
- SRTMGL1_E (SRTM GL1 Ellipsoidal 30m)
- AW3D30 (ALOS World 3D 30m)
- AW3D30_E (ALOS World 3D Ellipsoidal, 30m)
- SRTM15Plus (Global Bathymetry SRTM15+ V2.1)
- NASADEM (NASADEM Global DEM)
- COP30 (Copernicus Global DSM 30m)
- COP90 (Copernicus Global DSM 90m)
- EU_DTM (DTM 30m)
- GEDI_L3 (DTM 1000m)
- GEBCOIceTopo (Global Bathymetry 500m)
- GEBCOSubIceTopo (Global Bathymetry 500m)
- CAMRDEMDSM (DSM 30m)
- CAMRDEMDTM (DTM 30m)
as well as these USGS 3DEP raster datasets:
The library includes an API and a CLI that accept the dataset type, a latitude-longitude bounding box, and the output file format. Data are downloaded from OpenTopography and cached locally. The cache is checked before downloading new data. Data from a cached file can optionally be loaded into an xarray DataArray through rioxarray.
The bmi-topography API is wrapped with a Basic Model Interface (BMI), which provides a standard set of functions for coupling with data or models that also expose a BMI. More information on the BMI can found in its documentation.
Installation
Install the latest stable release of bmi-topography with pip:
pip install bmi-topography
or with conda:
conda install -c conda-forge bmi-topography
The bmi-topography library can also be built and installed from source.
The library uses several other open source libraries,
so a convenient way of building and installing it is within a
conda environment.
After cloning or downloading the bmi-topography
repository,
change into the repository directory
and set up a conda environment with the included environment file:
conda env create --file=environment.yml
Then build and install bmi-topography from source with
pip install -e .
API key
To better understand usage, OpenTopography requires an API key to access datasets they host. Getting an API key is easy, and it's free: just follow the instructions in the link above.
Once you have an API key, there are three ways to use it with bmi-topography:
- parameter: Pass the API key as a string through the
api_keyparameter. - environment variable: In the shell, set the
OPENTOPOGRAPHY_API_KEYenvironment variable to the API key value. - dot file: Put the API key in the file
.opentopography.txtin the current directory or in your home directory.
If you attempt to use bmi-topography to access an OpenTopography dataset without an API key,
you'll get an error like this:
requests.exceptions.HTTPError: 401 Client Error: This dataset requires an API Key for access.
Examples
A brief example of using the bmi-topography API is given in the following steps.
Start a Python session and import the Topography class:
```python
from bmi_topography import Topography ```
For convenience,
a set of default parameter values for Topography are included in the class definition.
Copy these and modify them with custom values:
```python
params = Topography.DEFAULT.copy() params["south"] = 39.93 params["north"] = 40.00 params["west"] = -105.33 params["east"] = -105.26 params {'demtype': 'SRTMGL3', 'south': 39.93, 'north': 40.0, 'west': -105.33, 'east': -105.26, 'outputformat': 'GTiff', 'cachedir': '~/.bmitopography'} ``` These coordinate values represent an area around Boulder, Colorado.
Make an instance of Topography with these parameters:
```python
boulder = Topography(**params)
Display the download URL:python boulder.url https://portal.opentopography.org/API/globaldem?demtype=SRTMGL3&south=39.93&north=40.0&west=-105.33&east=-105.26&outputFormat=GTiff&APIKey=demoapikeyot2022then fetch the data from OpenTopography:python boulder.fetch() PosixPath('/Users/mpiper/.bmitopography/SRTMGL339.93-105.3340.0-105.26.tif') ``` This step might take a few moments, and the time it takes will increase for requests of larger areas. Note that the file has been saved to a local cache directory.
Load the data into an xarray DataArray for further work:
```python
boulder.load()
array([[[2052, 2035, ..., 1645, 1643], [2084, 2059, ..., 1643, 1642], ..., [2181, 2170, ..., 1764, 1763], [2184, 2179, ..., 1773, 1769]]], dtype=int16) Coordinates: * band (band) int64 1 * x (x) float64 -105.3 -105.3 -105.3 ... -105.3 -105.3 -105.3 * y (y) float64 40.0 40.0 40.0 40.0 ... 39.93 39.93 39.93 39.93 spatialref int64 0 Attributes: _FillValue: 0.0 scalefactor: 1.0 add_offset: 0.0 units: meters location: node ```
Coordinate reference system (CRS) information is stored in the spatial_ref non-dimension coordinate:
```python
boulder.da.spatialref <xarray.DataArray 'spatialref' ()> array(0) Coordinates: spatialref int64 0 Attributes: crswkt: GEOGCS["WGS 84",DATUM["WGS1984",SPHEROID["... semimajoraxis: 6378137.0 semiminoraxis: 6356752.314245179 inverseflattening: 298.257223563 referenceellipsoidname: WGS 84 longitudeofprimemeridian: 0.0 primemeridianname: Greenwich geographiccrsname: WGS 84 gridmappingname: latitudelongitude spatialref: GEOGCS["WGS 84",DATUM["WGS1984",SPHEROID["... GeoTransform: -105.33041666668363 0.000833333333333144 0.... ```
Display the elevations with the default xarray DataArray plot method.
```python
import matplotlib.pyplot as plt boulder.da.plot() plt.show() ```

For examples with more detail, see the two Jupyter Notebooks, Python script, and shell script included in the examples directory of the bmi-topography repository.
User and developer documentation for bmi-topography is available at https://bmi-topography.csdms.io.
Owner
- Name: Community Surface Dynamics Modeling System
- Login: csdms
- Kind: organization
- Email: csdms@colorado.edu
- Website: http://csdms.colorado.edu
- Twitter: csdms
- Repositories: 65
- Profile: https://github.com/csdms
Cyberinfrastructure for the quantitative modeling of earth and planetary surface processes
Citation (CITATION.cff)
cff-version: 1.2.0
title: "CSDMS Topography data component"
message: >-
If you use this software, please cite it as below.
type: software
authors:
- family-names: Piper
given-names: Mark
orcid: 'https://orcid.org/0000-0001-6418-277X'
- family-names: Hutton
given-names: Eric
orcid: 'https://orcid.org/0000-0002-5864-6459'
url: 'https://github.com/csdms/bmi-topography'
abstract: >-
Fetch and cache land elevation data from OpenTopography through an API, BMI,
or CLI.
keywords:
- python
- copernicus
- srtm
- bmi
- topography
- csdms
- alos
- nasadem
- usgs
- gedi
- gebco
- mrdem
license: MIT
version: 0.9.0
doi: 10.5281/zenodo.4608652
date-released: 2025-06-26
GitHub Events
Total
- Create event: 17
- Issues event: 7
- Release event: 2
- Watch event: 1
- Delete event: 10
- Issue comment event: 22
- Push event: 24
- Pull request event: 22
Last Year
- Create event: 17
- Issues event: 7
- Release event: 2
- Watch event: 1
- Delete event: 10
- Issue comment event: 22
- Push event: 24
- Pull request event: 22
Committers
Last synced: 8 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Mark Piper | m****r@c****u | 202 |
| Eric Hutton | m****n | 5 |
| Jeffrey Kwang | j****g@g****m | 4 |
| Witold1 | 3****1 | 2 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 35
- Total pull requests: 72
- Average time to close issues: 3 months
- Average time to close pull requests: 19 days
- Total issue authors: 6
- Total pull request authors: 4
- Average comments per issue: 0.94
- Average comments per pull request: 0.75
- Merged pull requests: 65
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 6
- Pull requests: 26
- Average time to close issues: about 15 hours
- Average time to close pull requests: 4 days
- Issue authors: 2
- Pull request authors: 2
- Average comments per issue: 0.17
- Average comments per pull request: 0.81
- Merged pull requests: 20
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- mdpiper (28)
- BCampforts (3)
- mcflugen (2)
- Khalilsqu (1)
- Witold1 (1)
- jome1 (1)
Pull Request Authors
- mdpiper (68)
- mcflugen (5)
- Witold1 (4)
- jeffskwang (4)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 1,562 last-month
-
Total dependent packages: 3
(may contain duplicates) -
Total dependent repositories: 11
(may contain duplicates) - Total versions: 30
- Total maintainers: 1
pypi.org: bmi-topography
Fetch and cache land elevation data from OpenTopography
- Homepage: https://csdms.colorado.edu
- Documentation: https://bmi-topography.csdms.io/
- License: MIT License
-
Latest release: 0.9.0
published 8 months ago
Rankings
Maintainers (1)
conda-forge.org: bmi-topography
bmi-topography is a Python library that allows a user to fetch and cache land elevation data from multiple sources using the OpenTopography REST API. It presents the user with an API, CLI, and BMI.
- Homepage: https://csdms.colorado.edu/wiki/DataComponents
- License: MIT
-
Latest release: 0.7.1
published over 3 years ago
Rankings
Dependencies
- recommonmark *
- sphinx *
- AndreMiras/coveralls-python-action v20201129 composite
- actions/checkout v2 composite
- conda-incubator/setup-miniconda v2 composite
- actions/checkout v2 composite
- conda-incubator/setup-miniconda v2 composite
- actions/checkout v2 composite
- conda-incubator/setup-miniconda v2 composite
- bmipy *
- click *
- numpy *
- pyyaml *
- requests *
- rioxarray *
- xarray *