Summarize geospatial raster datasets based on vector geometries
Project description
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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for rasterstats-0.15.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b9c8de46125ac262187099962fa1b987797fca4e34180aabf8a688a6aa15044 |
|
MD5 | bb29acce29f4b5bf75ff0297111d85f8 |
|
BLAKE2b-256 | 9f52055b2b736e4aa1126c4619a561b44c3bc30fbe48025e6f3275b92928a0a0 |