• Stars
    star
    522
  • Rank 84,212 (Top 2 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created about 11 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Summary statistics of geospatial raster datasets based on vector geometries.

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.

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.

zones elevation

Command Line Quick Start

The command line interfaces to zonalstats and point_query are rio subcommands which read and write geojson features

$ fio cat polygon.shp | rio zonalstats -r elevation.tif

$ fio cat points.shp | rio pointquery -r elevation.tif

See the CLI Docs. for more detail.

Python Quick Start

For zonal statistics

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

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

More Repositories

1

simanneal

Python module for Simulated Annealing optimization
Python
628
star
2

pyimpute

Spatial classification and regression using Scikit-learn and Rasterio
Python
120
star
3

python-mbtiles

Python tools for working with mbtiles databases
Python
107
star
4

jenks

Cython implementation of jenks breaks
Python
105
star
5

leaflet-simple-csv

Put points on a map. CSV-driven, clustered, mobile-ready, filterable.
JavaScript
102
star
6

docker-gdal-base

A base docker image for geospatial applications
Dockerfile
58
star
7

geojson-precision

Adjust precision of GeoJSON coordinates
Python
56
star
8

pairing

Encode pairs of integers as single integer values using the Cantor pairing algorithm
Python
38
star
9

pytsp

Python interface to external TSP solvers
Python
31
star
10

bbox-cheatsheet

Reference for comparing software implementations of geospatial bounding boxes
25
star
11

gdal_utils

Random GDAL and OGR scripts to do useful stuff
Python
24
star
12

lambda-rasterio

Building Rasterio apps on AWS Lambda
Python
23
star
13

optimal_tour

Find the shortest tour visiting all GeoJSON points using concorde and mapbox APIs
Python
21
star
14

pi_sensor_realtime

Raspberry Pi, analog sensors, websockets and streaming real time plots
HTML
18
star
15

mower

mower - For controlling GRASS GIS with Python
Python
17
star
16

websocket-geojson-leaflet

Use WebSockets to stream GeoJSON features to a Leaflet map.
JavaScript
16
star
17

spatial-search-showdown

JavaScript
16
star
18

docker-postgres

PostgreSQL and PostGIS, dockerized
Shell
15
star
19

krige

Kriging for Geospatial Interpolation
Rust
10
star
20

smos

Tools for working with Soil Moisture and Ocean Salinity (SMOS) satellite data
Python
8
star
21

vagrant-webmaps

Deploy the ultimate web mapping server with a single command.
HTML
7
star
22

graph-kickr

Visualize Wahoo Kickr workout data
Python
7
star
23

raspberry_pi

Setting up a headless Raspberry Pi with automated code deployments
Python
6
star
24

batch-copy

Tokio actor to batch binary copies into PostgreSQL
Rust
3
star
25

ncvrt

Use VRTs to deal with some quirks of NetCDF and GDAL interaction
Python
3
star
26

projection-finder

Find EPSG Coordinate Reference Systems that match your bounds and criteria
Python
3
star
27

climate_explorer

CSS
3
star
28

pgconman

Manage PostgreSQL connection environment variables
Python
3
star
29

daylight

Visualize sunrise and sunset times
Clojure
3
star
30

climatedata

local point summaries and visualizations of global climate models
Python
3
star
31

notebooks

Personal dev logs as Jupyter notebooks
Jupyter Notebook
2
star
32

geojson-to-gljs

Generate Mapbox GL JS maps from GeoJSON features at the command line
Python
2
star
33

ctr-mtb

Colorado Trail Race Map, MTB
HTML
2
star
34

ghtix

Tools for working with github issue tracker
Python
2
star
35

ergplayer

Little GUI app to "play" .erg files as you ride.
Python
2
star
36

example-mapserver-rs

A proof-of-concept HTTP server and bindings for UMN Mapserver, implemented in Rust
Rust
2
star
37

rio-combine

Find unique combinations of values for two rasters/arrays
Python
2
star
38

fio-stats

Summary statistics for GeoJSON feature properties
Python
2
star
39

csv2sqlite

Does what it says; converts csvs to sqlite tables
Python
2
star
40

geodesicxy

Extract distances and properties over GeoJSON points
Python
1
star
41

archive

old projects for purely historical purposes
JavaScript
1
star
42

mapbox-directions-ui

A MapboxGLJS and Elm interface to mapbox geocoding, directions and trip optimization APIs
Elm
1
star
43

pylas

Automatically exported from code.google.com/p/pylas
Python
1
star
44

rusty-python

Demo: add a little Rust to your Python projects.
Python
1
star
45

wikipedia-geo

Extract and filter geographic data from wikipedia
Python
1
star
46

openpayments

Geography of Health Care Industry Payments, http://perrygeo.github.io/openpayments
JavaScript
1
star
47

geofu

Geofu
Python
1
star
48

iterpipe

Processing pipelines for Python iterables
Python
1
star
49

dockermon

CLI to simplify local monitoring of a docker container's resource usage
Rust
1
star