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.svg
.. _BuildStatus: https://travis-ci.org/perrygeo/python-rasterstats

.. |CoverageStatus| image:: https://coveralls.io/repos/github/perrygeo/python-rasterstats/badge.svg?branch=master
.. _CoverageStatus: https://coveralls.io/github/perrygeo/python-rasterstats?branch=master


Project details


Download files

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

Source Distribution

rasterstats-0.13.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

rasterstats-0.13.0-py2.py3-none-any.whl (17.6 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: rasterstats-0.13.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/38.5.0 requests-toolbelt/0.8.0 tqdm/4.19.6 CPython/3.6.3

File hashes

Hashes for rasterstats-0.13.0.tar.gz
Algorithm Hash digest
SHA256 8d2a59bdcf1ebf882ecbb2f511b180f05c14b0b70813d4a805cd91c4326765b7
MD5 0552bb25edb29b0598f0350a4ce50f35
BLAKE2b-256 4f4cce5965d004368fbc7998de9ed82b24d242c1211bf0c4152e67160288295a

See more details on using hashes here.

File details

Details for the file rasterstats-0.13.0-py2.py3-none-any.whl.

File metadata

  • Download URL: rasterstats-0.13.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/38.5.0 requests-toolbelt/0.8.0 tqdm/4.19.6 CPython/3.6.3

File hashes

Hashes for rasterstats-0.13.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 674f3a21d036cd3d13ffd1befa51af2d6ee296e5fb63fc1da597c021431b59ac
MD5 834905e10f8341661617f576b3f3b149
BLAKE2b-256 37e4eab870a3ca8bf8e261a71d841fa54175a155de6de7d60d63c00701ea34a1

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