Skip to main content

Summarize geospatial raster datasets based on vector geometries

Project description

BuildStatus CoverageStatus

rasterstats is a Python module for summarizing geospatial raster datasets based on vector geometries. It includes functions for zonal statistics and interpolated point queries. The command-line interface allows for easy interoperability with other GeoJSON tools.

Documentation

For details on installation and usage, visit the documentation at http://pythonhosted.org/rasterstats.

What does it do?

Given a vector layer and a raster band, calculate the summary statistics of each vector geometry. For example, with a polygon vector layer and a digital elevation model (DEM) raster, compute the mean elevation of each polygon.

zones elevation

Command Line Quick Start

The command line interfaces to zonalstats and point_query are rio subcommands which read and write geojson features

$ fio cat polygon.shp | rio zonalstats -r elevation.tif

$ fio cat points.shp | rio pointquery -r elevation.tif

See the CLI Docs. for more detail.

Python Quick Start

For zonal statistics

>>> from rasterstats import zonal_stats
>>> stats = zonal_stats("tests/data/polygons.shp", "tests/data/elevation.tif")
>>> stats[1].keys()
['count', 'min', 'max', 'mean']
>>> [f['mean'] for f in stats]
[756.6057470703125, 114.660084635416666]

and for point queries

>>> from rasterstats import point_query
>>> point = "POINT(245309 1000064)"
>>> point_query(point, "tests/data/elevation.tif")
[723.9872347624]

Issues

Find a bug? Report it via github issues by providing

  • a link to download the smallest possible raster and vector dataset necessary to reproduce the error

  • python code or command to reproduce the error

  • information on your environment: versions of python, gdal and numpy and system memory

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

rasterstats-0.14.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

rasterstats-0.14.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file rasterstats-0.14.0.tar.gz.

File metadata

  • Download URL: rasterstats-0.14.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.1

File hashes

Hashes for rasterstats-0.14.0.tar.gz
Algorithm Hash digest
SHA256 b7b19c620934e8f7c81b1c5456ade63673831cd1e02c7361514b5bf1d08c23e4
MD5 a32dce38eb8b4c4bf5f2751f3022cadb
BLAKE2b-256 4239d7483b401003e23bb51cfb889ce9c0f8d44bb8b87bcc95b7b9a596212074

See more details on using hashes here.

File details

Details for the file rasterstats-0.14.0-py3-none-any.whl.

File metadata

  • Download URL: rasterstats-0.14.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.1

File hashes

Hashes for rasterstats-0.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 287b74d11739f8a0ced0b969a1fa6847fdb55d54278d90dfce75e93163f6623f
MD5 f5fc1c8c29070b1a078f39fa36d259ff
BLAKE2b-256 bd86493e7794124d1048254bd3be562839506a4ea1777d7ce28313b1d2a24312

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