bmi-topography

Fetch and cache land elevation data from OpenTopography through an API, BMI, or CLI

https://github.com/csdms/bmi-topography

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

alos bmi copernicus csdms gebco gedi mrdem nasadem python srtm topography usgs
Last synced: 6 months ago · JSON representation ·

Repository

Fetch and cache land elevation data from OpenTopography through an API, BMI, or CLI

Basic Info
Statistics
  • Stars: 11
  • Watchers: 6
  • Forks: 4
  • Open Issues: 8
  • Releases: 4
Topics
alos bmi copernicus csdms gebco gedi mrdem nasadem python srtm topography usgs
Created about 5 years ago · Last pushed 8 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.md

DOI Conda Version PyPI Build/Test CI Coverage Status Documentation Status

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:

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:

  1. parameter: Pass the API key as a string through the api_key parameter.
  2. environment variable: In the shell, set the OPENTOPOGRAPHY_API_KEY environment variable to the API key value.
  3. dot file: Put the API key in the file .opentopography.txt in 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=demoapikeyot2022 then 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() ```

Example elevation data displayed through *xarray*.

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

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

All Time
  • Total Commits: 213
  • Total Committers: 4
  • Avg Commits per committer: 53.25
  • Development Distribution Score (DDS): 0.052
Past Year
  • Commits: 98
  • Committers: 2
  • Avg Commits per committer: 49.0
  • Development Distribution Score (DDS): 0.01
Top Committers
Name Email 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
enhancement (13) question (1) documentation (1) bug (1)
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

  • Versions: 20
  • Dependent Packages: 2
  • Dependent Repositories: 8
  • Downloads: 1,562 Last month
Rankings
Dependent packages count: 3.2%
Dependent repos count: 5.3%
Downloads: 11.3%
Average: 12.6%
Stargazers count: 20.4%
Forks count: 22.8%
Maintainers (1)
Last synced: 6 months ago
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.

  • Versions: 10
  • Dependent Packages: 1
  • Dependent Repositories: 3
Rankings
Dependent repos count: 17.9%
Dependent packages count: 29.0%
Average: 42.1%
Stargazers count: 59.4%
Forks count: 62.1%
Last synced: 6 months ago

Dependencies

docs/source/requirements.txt pypi
  • recommonmark *
  • sphinx *
.github/workflows/build-test-ci.yml actions
  • AndreMiras/coveralls-python-action v20201129 composite
  • actions/checkout v2 composite
  • conda-incubator/setup-miniconda v2 composite
.github/workflows/docs.yml actions
  • actions/checkout v2 composite
  • conda-incubator/setup-miniconda v2 composite
.github/workflows/format.yml actions
  • actions/checkout v2 composite
  • conda-incubator/setup-miniconda v2 composite
pyproject.toml pypi
  • bmipy *
  • click *
  • numpy *
  • pyyaml *
  • requests *
  • rioxarray *
  • xarray *
environment.yml pypi