--- id: rasterstats version: "0.21.0" license: BSD-3-Clause license_treatment: permissive maintenance: active --- # rasterstats — Summarize geospatial raster datasets based on vector geometries License: permissive · Maintenance: active · Downloads: 439.4K/mo ## 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 above — verify before relying. Rasterstats computes summary statistics (mean, min, max, count) from raster datasets for vector geometries, and queries raster values at point locations. 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 pip install rasterstats uv add rasterstats poetry add rasterstats ## Installing rasterstats 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. 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']) Requires rasterio and its system dependencies (GDAL/GEOS libraries); vector and raster files must be accessible on disk or via a path. 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_current - Install friction: low - Maintenance: active - Downloads: 439.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags zonal statistics raster vector, raster summarization by geometry, extract raster values polygons, point query raster data, geospatial raster analysis, dem statistics polygon, raster zonal summary, geospatial, raster-vector, gis [View on SkillFed](https://skillfed.io/packages/rasterstats) · [View on PyPI](https://pypi.org/project/rasterstats/)