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

Uploaded Source

Built Distribution

rasterstats-0.16.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rasterstats-0.16.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10

File hashes

Hashes for rasterstats-0.16.0.tar.gz
Algorithm Hash digest
SHA256 ad04711931fd8f02a5982115a2a03036c1420dfe31497a3d3de8e9d891f0357d
MD5 e9f4966f1acc6c002ff59d3637f190f9
BLAKE2b-256 36ab4de956080f7f1a278ee3ab29c1ed67799eefac56edb1413a06263c8b05cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rasterstats-0.16.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10

File hashes

Hashes for rasterstats-0.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ec669951fb67bc917e45c0575f4a6625c1302a009a88346f74d4fee76c1992a
MD5 0c2f1f6728565ebfd3e23f8bbe1aa037
BLAKE2b-256 48ba1001fbe5dfce9867114fde28a76c99a47dfedfa45dda9a636edf03092534

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