Skip to main content

Summarize geospatial raster datasets based on vector geometries

Project description

BuildStatus

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/slope.tif")
>>> stats[0].keys()
dict_keys(['min', 'max', 'mean', 'count'])
>>> [f['mean'] for f in stats]
[14.660084635416666, 56.60576171875]

and for point queries

>>> from rasterstats import point_query
>>> point = {'type': 'Point', 'coordinates': (245309.0, 1000064.0)}
>>> point_query(point, "tests/data/slope.tif")
[74.09817594635244]

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.18.0.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

rasterstats-0.18.0-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rasterstats-0.18.0.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for rasterstats-0.18.0.tar.gz
Algorithm Hash digest
SHA256 29389bfcbeac1a4206aba6e1d795058ec8a64d560efad48156c27fad97c2e09a
MD5 2c9047bfe259ac45708be3506c36055d
BLAKE2b-256 af372fb43c8a9235c5b556717a361a7e8d01c18c2a92d0a508637b4ccaaf0325

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rasterstats-0.18.0-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for rasterstats-0.18.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00014f422160f6047d3431c9132ebe3d356021ca8e22c6f40d04764f98a60795
MD5 bac4f76dff160ea83f450ed18dd8bd48
BLAKE2b-256 82a941b9061fee783b139031e18d99891e94d9a0b95de7775d9d911b819e80f3

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