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
Metadata
Release files for rasterstats 0.13.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rasterstats-0.13.1.tar.gz | 13.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rasterstats-0.13.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.1 kB
Release files / rasterstats-0.13.1.tar.gz
| Download URL | rasterstats-0.13.1.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5600e58a80d9968a1afa8e25fc06e1e54cdfa7d078cb239db574b23167d0f0de
|
|
BLAKE2b-256 checksum How to use checksums |
01b6d2b7dd768ad89999eecef99c781227f1bcab51601903497e75db21e97307
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8
|
Release files / rasterstats-0.13.1-py3-none-any.whl
| Download URL | rasterstats-0.13.1-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a38387a62c0b2e09fbf7b8d49e25c71fb3e63f0b893d0a82590ec36a8e2b662f
|
|
BLAKE2b-256 checksum How to use checksums |
43307f0b3ed0debd10a6687110dd9d46b308d33ff4696b88c2461758d86ff428
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8
|