Skip to main content

Python script to download global terrain digital elevation models, SRTM 30m DEM and SRTM 90m DEM.

Project description

Global geographic elevation data made easy. Elevation provides easy download, cache and access of the global datasets SRTM 30m Global 1 arc second V003 elaborated by NASA and NGA hosted on Amazon S3 and SRTM 90m Digital Elevation Database v4.1 elaborated by CGIAR-CSI.

Note that any download policies of the respective providers apply.

Installation

Install the latest version of Elevation from the Python Package Index:

$ pip install elevation

The following dependencies need to be installed and working:

The following command runs some basic checks and reports common issues:

$ eio selfcheck
Your system is ready.

GNU make, curl and unzip come pre-installed with most operating systems. The best way to install GDAL command line tools varies across operating systems and distributions, please refer to the GDAL install documentation.

Command line usage

Identify the geographic bounds of the area of interest and fetch the DEM with the eio command. For example to clip the SRTM 30m DEM of Rome, around 41.9N 12.5E, to the Rome-30m-DEM.tif file:

$ eio clip -o Rome-30m-DEM.tif --bounds 12.35 41.8 12.65 42

For the SRTM 90m DEM use:

$ eio --product SRTM3 clip -o Rome-90m-DEM.tif --bounds 12.35 41.8 12.65 42

The --bounds option accepts latitude and longitude coordinates (more precisely in geodetic coordinates in the WGS84 refernce system EPSG:4326 for those who care) given as left bottom right top similarly to the rio command form rasterio.

If you have installed the packages rasterio and fiona you can clip a DEM on the same extent of any other geospatial data source supported by GDAL and OGR, for example if you have a georeference image MyImage.tif you can clip the corresponding DEM with:

$ eio clip -o MyImage-DEM.tif --reference MyImage.tif  # enable with: $ pip install rasterio

The --reference option can take also verctor data as input:

$ eio clip -o MyShapefile-DEM.tif --reference MyShapefile.shp  # enable with: $ pip install fiona

The first time an area is accessed Elevation downloads the data tiles from the USGS or CGIAR-CSI servers and caches them in GeoTiff compressed formats, subsequent accesses to the same and nearby areas are much faster.

The clip sub-command doesn’t allow automatic download of a large amount of DEM tiles, please refer to the upstream providers’ websites to learn the preferred procedures for bulk download.

To clean up stale temporary files and fix the cache in the event of a server error use:

$ eio clean

Command line reference

The eio command as the following sub-commands and options:

$ Usage: eio [OPTIONS] COMMAND [ARGS]...

Options:
  --version                Show the version and exit.
  --product [SRTM1|SRTM3]  DEM product choice.  [default: SRTM1]
  --cache_dir DIRECTORY    Root of the DEM cache folder.  [default:
                           /Users/amici/Library/Caches/elevation]
  --help                   Show this message and exit.

Commands:
  clean      Clean up the product cache from temporary files.
  clip       Clip the DEM to given bounds.
  distclean  Remove the product cache entirely.
  info       Show info about the product cache.
  seed       Seed the DEM to given bounds.
  selfcheck  Audit the system for common issues.

The clip sub-command:

$ eio clip --help
Usage: eio clip [OPTIONS]

Options:
  -o, --output PATH     Path to output file. Existing files will be
                        overwritten.  [default: out.tif]
  --bounds FLOAT...     Output bounds in 'left bottom right top' order.
  -m, --margin TEXT     Decimal degree margin added to the bounds. Use '%' for
                        percent margin.  [default: 0]
  -r, --reference TEXT  Use the extent of a reference GDAL/OGR data source as
                        output bounds.
  --help                Show this message and exit.

Defaults can be defined by setting environment variables prefixed with EIO, e.g. EIO_PRODUCT=SRTM3 and EIO_CLIP_MARGIN=10%.

Python API

Every command has a corresponding API function in the elevation module:

>>> import elevation
>>> # clip the SRTM1 30m DEM of Rome and save it to Rome-DEM.tif
>>> elevation.clip(bounds=(12.35, 41.8, 12.65, 42), output='Rome-DEM.tif')
>>> # clean up stale temporary files and fix the cache in the event of a server error
>>> elevation.clean()

Project resources

Documentation

http://elevation.bopen.eu

Support

https://stackoverflow.com/search?q=python+elevation

Development

https://github.com/bopen/elevation

Download

https://pypi-hypernode.com/project/elevation

Code quality

Build Status on Travis CI Coverage Status on Coveralls

Contributing

Contributions are very welcome. Please see the CONTRIBUTING document for the best way to help. If you encounter any problems, please file an issue along with a detailed description.

Authors:

License

Elevation is free and open source software distributed under the terms of the Apache License, Version 2.0.

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

elevation-1.0.5.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

elevation-1.0.5-py2.py3-none-any.whl (12.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file elevation-1.0.5.tar.gz.

File metadata

  • Download URL: elevation-1.0.5.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.6

File hashes

Hashes for elevation-1.0.5.tar.gz
Algorithm Hash digest
SHA256 12a8c0f9428efd2609eb6e0fd761a1ba340fa05d1b075ff22bf7efa417e96ec4
MD5 6a53e282b688f3f8da4b68736f222911
BLAKE2b-256 e8ec8e92c87343e143fbe99117e8547ec0b549f6501cffc0d1c8d47b48002e4c

See more details on using hashes here.

File details

Details for the file elevation-1.0.5-py2.py3-none-any.whl.

File metadata

  • Download URL: elevation-1.0.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.6

File hashes

Hashes for elevation-1.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 73d71f4c92e4fa5078eafcfcc8ae92d3ca3276267dedde4a3cae07f73ab337e7
MD5 53813b6b9a54203e1e13b1b67c9880be
BLAKE2b-256 4754c91e9918c798ee0a7f71b3ebbe65e70059de210d3df6c7c64fe8f10cc9dc

See more details on using hashes here.

Supported by

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