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/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
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
File details
Details for the file rasterstats-0.17.0.tar.gz
.
File metadata
- Download URL: rasterstats-0.17.0.tar.gz
- Upload date:
- Size: 16.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27975ebc0a402865dd9e92ad4ecf0dd62678e320735cc81e104c730e6d001298 |
|
MD5 | c3a3c33a0b20b4132f45746e889ba2ed |
|
BLAKE2b-256 | 6851e10652e7a687f9293a334cec4beff3b39d90b8b6ea321eeb24ca8b4a2a98 |
File details
Details for the file rasterstats-0.17.0-py3-none-any.whl
.
File metadata
- Download URL: rasterstats-0.17.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | b003bf9888c22d416d3af08deb288f7ea0e406a2c593ebc0386cbf96786e5195 |
|
MD5 | 3bee3082cd7888ce2661edd8550ff1dd |
|
BLAKE2b-256 | fdf2fb998f425aab6f3d2fbb574880349714c8756bd3a025186d9e8fe1aee8aa |