rasterstats
===========
|BuildStatus|_
``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/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
.. code-block:: python
>>> 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
.. |BuildStatus| image:: https://github.com/perrygeo/python-rasterstats/workflows/Rasterstats%20Python%20package/badge.svg
.. _BuildStatus: https://github.com/perrygeo/python-rasterstats/actions
Raw data
{
"_id": null,
"home_page": null,
"name": "rasterstats",
"maintainer": null,
"docs_url": "https://pythonhosted.org/rasterstats/",
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "gis, geospatial, geographic, raster, vector, zonal statistics",
"author": null,
"author_email": "Matthew Perry <perrygeo@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/09/3d/6a32a149e494b9b3f17edc4243843563a899b1ab4feb680f22bf688bd189/rasterstats-0.20.0.tar.gz",
"platform": null,
"description": "rasterstats\n===========\n\n|BuildStatus|_\n\n``rasterstats`` is a Python module for summarizing geospatial raster datasets based on vector geometries.\nIt includes functions for **zonal statistics** and interpolated **point queries**. The command-line interface allows for\neasy interoperability with other GeoJSON tools.\n\nDocumentation\n-------------\nFor details on installation and usage, visit the documentation at `http://pythonhosted.org/rasterstats <http://pythonhosted.org/rasterstats/>`_.\n\nWhat does it do?\n----------------\nGiven a vector layer and a raster band, calculate the summary statistics of each vector geometry.\nFor example, with a polygon vector layer and a digital elevation model (DEM) raster, compute the\nmean elevation of each polygon.\n\n.. figure:: https://github.com/perrygeo/python-raster-stats/raw/master/docs/img/zones_elevation.png\n :align: center\n :alt: zones elevation\n\nCommand Line Quick Start\n------------------------\n\nThe command line interfaces to zonalstats and point_query\nare `rio` subcommands which read and write geojson features\n\n.. code-block:: bash\n\n $ fio cat polygon.shp | rio zonalstats -r elevation.tif\n\n $ fio cat points.shp | rio pointquery -r elevation.tif\n\nSee the `CLI Docs <http://pythonhosted.org/rasterstats/cli.html>`_. for more detail.\n\nPython Quick Start\n------------------\n\nFor zonal statistics\n\n.. code-block:: python\n\n >>> from rasterstats import zonal_stats\n >>> stats = zonal_stats(\"tests/data/polygons.shp\", \"tests/data/slope.tif\")\n >>> stats[0].keys()\n dict_keys(['min', 'max', 'mean', 'count'])\n >>> [f['mean'] for f in stats]\n [14.660084635416666, 56.60576171875]\n\nand for point queries\n\n.. code-block:: python\n\n >>> from rasterstats import point_query\n >>> point = {'type': 'Point', 'coordinates': (245309.0, 1000064.0)}\n >>> point_query(point, \"tests/data/slope.tif\")\n [74.09817594635244]\n\n\nIssues\n------\n\nFind a bug? Report it via github issues by providing\n\n- a link to download the smallest possible raster and vector dataset necessary to reproduce the error\n- python code or command to reproduce the error\n- information on your environment: versions of python, gdal and numpy and system memory\n\n.. |BuildStatus| image:: https://github.com/perrygeo/python-rasterstats/workflows/Rasterstats%20Python%20package/badge.svg\n.. _BuildStatus: https://github.com/perrygeo/python-rasterstats/actions\n",
"bugtrack_url": null,
"license": "BSD-3-Clause",
"summary": "Summarize geospatial raster datasets based on vector geometries",
"version": "0.20.0",
"project_urls": {
"Documentation": "https://pythonhosted.org/rasterstats/",
"Source Code": "https://github.com/perrygeo/python-rasterstats"
},
"split_keywords": [
"gis",
" geospatial",
" geographic",
" raster",
" vector",
" zonal statistics"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5e0bbd73621d2a5f87da97158c5c77a4bf31e27d60cf6bcc6ddea532043cc21d",
"md5": "a6edf8d8c0f9b0d7ad4b3d274310eab1",
"sha256": "a7015e99f42807842b8638d489157639ff0cbf8e35aac9647aa3e079982b18ee"
},
"downloads": -1,
"filename": "rasterstats-0.20.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a6edf8d8c0f9b0d7ad4b3d274310eab1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 17280,
"upload_time": "2024-09-27T17:42:53",
"upload_time_iso_8601": "2024-09-27T17:42:53.889005Z",
"url": "https://files.pythonhosted.org/packages/5e/0b/bd73621d2a5f87da97158c5c77a4bf31e27d60cf6bcc6ddea532043cc21d/rasterstats-0.20.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "093d6a32a149e494b9b3f17edc4243843563a899b1ab4feb680f22bf688bd189",
"md5": "7e7939a7f45a8dad5308b1ba5d81fdc0",
"sha256": "5b8ee775e815727767e0d359c03f3dd1c7840876d1d1d0c7a5a88ecf3e492938"
},
"downloads": -1,
"filename": "rasterstats-0.20.0.tar.gz",
"has_sig": false,
"md5_digest": "7e7939a7f45a8dad5308b1ba5d81fdc0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 24017,
"upload_time": "2024-09-27T17:42:55",
"upload_time_iso_8601": "2024-09-27T17:42:55.355628Z",
"url": "https://files.pythonhosted.org/packages/09/3d/6a32a149e494b9b3f17edc4243843563a899b1ab4feb680f22bf688bd189/rasterstats-0.20.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-27 17:42:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "perrygeo",
"github_project": "python-rasterstats",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "rasterstats"
}