skip to navigation
skip to content

rasterstats 0.12.1

Summarize geospatial raster datasets based on vector geometries

Package Documentation



``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.

For details on installation and usage, visit the documentation at ` <http:"" 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.

.. figure::
:align: center
:alt: zones elevation

Command Line Quick Start

The command line interfaces to zonalstats and point_query
are `rio` subcommands which read and write geojson features

.. code-block:: bash

$ fio cat polygon.shp | rio zonalstats -r elevation.tif

$ fio cat points.shp | rio pointquery -r elevation.tif

See the `CLI Docs <http:"" rasterstats="" cli.html="">`_. for more detail.

Python Quick Start

For zonal statistics

.. code-block:: python

>>> 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

.. code-block:: python

>>> from rasterstats import point_query
>>> point = "POINT(245309 1000064)"
>>> point_query(point, "tests/data/elevation.tif")


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

.. |BuildStatus| image::
.. _BuildStatus:

.. |CoverageStatus| image::
.. _CoverageStatus:

File Type Py Version Uploaded on Size
rasterstats-0.12.1-py2.py3-none-any.whl (md5) Python Wheel py2.py3 2018-02-22 17KB
rasterstats-0.12.1.tar.gz (md5) Source 2018-02-22 13KB