Skip to main content

Wrapper around rasterio to query points on a Digital Elevation Model

Project description

demquery

Pypi Downloads Supported Python Versions

Wrapper around rasterio to query points on a Digital Elevation Model.

Features

  • Use multiple raster files without having to merge them into a new file
  • Query many points at once
  • Optional 2D interpolation (linear, cubic, or quintic)
  • Reasonably performant by reading the minimal data required from raster

Install

I recommend first installing dependencies with Conda, then installing demquery itself with pip.

conda install gdal rasterio numpy scipy -c conda-forge
pip install demquery

CLI Script

> demquery --help
Usage: demquery [OPTIONS] FEATURES...

  Assign elevations to GeoJSON

Options:
  -d, --dem PATH          Paths to DEM files.  [required]
  -g, --dem-glob TEXT     Glob expression for DEM paths if folder is provided.
  -b, --band INTEGER      Band of rasters to use  [default: 1]
  -i, --interp-kind TEXT  either None, "linear", "cubic", or "quintic". None
                          will do no interpolation and choose the value in the
                          DEM closest to the provided point. linear creates a
                          3x3 grid and runs linear interpolation; cubic
                          creates a 5x5 grid and runs cubic interpolation;
                          quintic creates a 7x7 grid and runs quintic
                          interpolation.
  --help                  Show this message and exit.
echo \
    '{"type":"Feature","properties":{"name": "Glacier Peak"},"geometry":{"type":"Point","coordinates":[-121.2436843,48.0163834]}}' \
    | demquery -d /path/to/dem/files

Outputs:

{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [-121.243684, 48.016383, 1431.5755615234375]}, "properties": {"name": "Glacier Peak"}}]}

Documentation

from demquery import Query

dem_paths = ['dem1.tif', 'dem2.tif']
query = Query(dem_paths)

# Points must be in longitude, latitude order!
# These points are in Manhattan, not Antarctica
points = [(-73.985564, 40.757965), (-73.968520, 40.778912)]
elevations = query.query_points(points, interp_kind='linear')

Data Download

For a great visual tool to download worldwide SRTM data, check out these sites:

Releasing

To upload a new release to PyPI

python setup.py sdist
twine upload dist/demquery-0.3.0.tar.gz

Changelog

[0.3.1] - 2020-08-19

  • No changes: try to get conda-forge package to work correctly

[0.3.0] - 2020-01-28

  • Add CLI script

[0.2.1] - 2019-12-04

  • Include requirements.txt and requirements_dev.txt in manifest bundle

[0.2.0] - 2019-12-02

  • Fix virtual raster issues.

[0.1.0] - 2019-11-27

  • Initial release on PyPI

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

demquery-0.3.1.tar.gz (11.4 kB view details)

Uploaded Source

File details

Details for the file demquery-0.3.1.tar.gz.

File metadata

  • Download URL: demquery-0.3.1.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.7

File hashes

Hashes for demquery-0.3.1.tar.gz
Algorithm Hash digest
SHA256 aaf59a283933dc43b2ac1f2097d85e4220bbdb46fa4b52e2879e111fcd687575
MD5 5a18842dd2da50d73ad943d83e47a86e
BLAKE2b-256 8cd879a01d2a509da25f5addd102e7537fb1da225fed8144da7e78561aad08fd

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