rasterstats
Summarize geospatial raster datasets based on vector geometries
Decision gist · record as of 2026-08-14
Yes. Rasterstats is actively maintained, has no known vulnerabilities, low install friction, and solves a common GIS task (zonal statistics) that would otherwise require custom spatial code. It is well-suited for anyone working with raster and vector data in Python, from climate and environmental analysis to remote sensing. The permissive BSD license poses no restriction.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires rasterio and its system dependencies (GDAL/GEOS libraries); vector and raster files must be accessible on disk or via a path.
- Low friction: pure Python wheel with no compiled dependencies beyond rasterio and its transitive stack.
- Actively maintained with a recent release (83 days old) and steady commit history.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause is permissive; you may use, modify, and distribute rasterstats freely in commercial and proprietary projects provided you include the license text and disclaim liability.
last release 2026-05-23 (83 days) · last repo commit 2026-05-23 · 561 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 439,438 downloads/mo, #6,655 on PyPI
Alternatives
Verify before relying
pip install rasterstats
from rasterstats import zonal_stats
stats = zonal_stats("polygons.shp", "elevation.tif")
print(stats[0]['mean'])- Performance characteristics with large raster datasets or many geometries are not documented in the fact sheet.
- Whether the package supports cloud-optimized GeoTIFF or remote raster sources via rasterio's capabilities is unclear from the description.
What it is and what it does
Rasterstats is a geospatial analysis library that bridges raster and vector data by computing statistics from raster datasets within vector geometry boundaries. Given a vector layer (polygons, lines, or points) and a raster band (such as a digital elevation model), it calculates aggregate statistics like mean, min, max, and count for each geometry. It also supports point queries to extract raster values at specific coordinates. The package wraps rasterio for raster I/O and shapely for geometry handling, and provides both a Python API and command-line interfaces (via rio subcommands) for integration with GeoJSON workflows.
The library is designed for GIS workflows where you need to summarize continuous raster data (elevation, temperature, precipitation, satellite imagery) by administrative or analytical boundaries. It handles the geometric intersection and pixel aggregation internally, making it straightforward to compute landscape statistics for polygons or sample raster values at point locations without writing custom spatial indexing code.
Use it for
- Calculate mean elevation or slope within each administrative boundary (county, watershed, grid cell) from a DEM.
- Extract average temperature or precipitation values for polygon regions from climate raster datasets.
- Query satellite imagery or land-use raster values at survey point locations for classification or validation.
- Summarize vegetation indices (NDVI) or other derived rasters across field polygons for agricultural analysis.
- Batch compute zonal statistics from the command line by piping GeoJSON features through rio subcommands.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Rasterstats is actively maintained, has no known vulnerabilities, low install friction, and solves a common GIS task (zonal statistics) that would otherwise require custom spatial code. It is well-suited for anyone working with raster and vector data in Python, from climate and environmental analysis to remote sensing. The permissive BSD license poses no restriction.
Install
rasterstats on PyPI
Before you install
Low friction: pure Python wheel with no compiled dependencies beyond rasterio and its transitive stack. Actively maintained with a recent release (83 days old) and steady commit history.
Requires rasterio and its system dependencies (GDAL/GEOS libraries); vector and raster files must be accessible on disk or via a path.
License in practice
BSD-3-Clause is permissive; you may use, modify, and distribute rasterstats freely in commercial and proprietary projects provided you include the license text and disclaim liability.
Quickstart
pip install rasterstats
from rasterstats import zonal_stats
stats = zonal_stats("polygons.shp", "elevation.tif")
print(stats[0]['mean'])
Verify before relying
- Performance characteristics with large raster datasets or many geometries are not documented in the fact sheet.
- Whether the package supports cloud-optimized GeoTIFF or remote raster sources via rasterio's capabilities is unclear from the description.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 8 packagesaffineclickcligjnumpypyogriorasterioshapelysimplejson |
| Maintenance | Actively maintained 83 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 439,438 / month, #6,655 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: GISTopic :: Utilities |
Evidence: rasterstats-0.21.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “zonal statistics raster vector”
- rasterstatsRasterstats computes summary statistics (mean, min, max, count) from…
- exactextractexactextract computes zonal statistics—fast summaries of raster…
- geemapGeemap provides interactive geospatial analysis and visualization of…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also exactextract · runstats · rasterio · statistics · GDAL · xarray-spatial · leafmap · stats-can · facets-overview · arcgis