Skip to main content

Summarize geospatial raster datasets based on vector geometries

Project description

rasterstats
===========

|BuildStatus|_
|CoverageStatus|_

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

.. figure:: https://github.com/perrygeo/python-raster-stats/raw/master/docs/img/zones_elevation.png
: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://pythonhosted.org/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")
[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

.. |BuildStatus| image:: https://api.travis-ci.org/perrygeo/python-rasterstats.png
.. _BuildStatus: https://travis-ci.org/perrygeo/python-rasterstats

.. |CoverageStatus| image:: https://coveralls.io/repos/perrygeo/python-rasterstats/badge.png
.. _CoverageStatus: https://coveralls.io/r/perrygeo/python-raster-stats

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

rasterstats-0.10.2.zip (19.9 kB view details)

Uploaded Source

rasterstats-0.10.2.tar.gz (14.5 kB view details)

Uploaded Source

File details

Details for the file rasterstats-0.10.2.zip.

File metadata

  • Download URL: rasterstats-0.10.2.zip
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rasterstats-0.10.2.zip
Algorithm Hash digest
SHA256 88ff91aaedfaddce64873821d565b0cdef2ca7efea533927cb1847ea6dc3de9c
MD5 88457c64fc6761185be0ed20daeb37c7
BLAKE2b-256 df0c46fc7e332719ed1585289caf1f4ebe1f1ad7a599f72fd2e3ba3c8bc13120

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterstats-0.10.2.tar.gz
Algorithm Hash digest
SHA256 ffd1b75d59f6058df9cd21747da9d47daed80e51a94efb0adc026114cdb1c88b
MD5 4722d5eb209c3c6fb8894a6e76085578
BLAKE2b-256 84e4a041d01cadad7f40e1146452f2b794743f1508cc12da9e52955186bf217f

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