Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
9a12cc7
workaround for numpy on win 64bit, resolves #129
perrygeo Feb 22, 2018
aa1a391
pep8
perrygeo Feb 22, 2018
0bdb4da
use rasterio 1 for CI testing b/c wheels
perrygeo Feb 22, 2018
f7fd296
versions
perrygeo Feb 22, 2018
cb3e6d5
we support python 3.6 officially, resolves #149
perrygeo Feb 22, 2018
58692a0
Merge pull request #159 from perrygeo/castaway
perrygeo Feb 22, 2018
23b0022
Remove use of deprecated functionality
Apr 11, 2018
9eb57b7
Merge pull request #167 from whistler/patch-1
perrygeo Apr 11, 2018
f2f5c27
Fix boxify_points to correctly use a negative buffer
sgoodm Aug 8, 2018
2d4962c
use the rasterio dataset's .transform property; require Rasterio 1.0
perrygeo Aug 10, 2018
e74152d
Merge pull request #171 from perrygeo/rasterio-1.0-transform
perrygeo Aug 10, 2018
e324dad
Merge pull request #170 from sgoodm/fix_boxify_points
perrygeo Aug 10, 2018
b5727bf
bump version 0.13.0
perrygeo Aug 10, 2018
5a105ad
Fix README markup and add twine check
chadwhawkins Oct 24, 2018
a36c903
Merge pull request #174 from chadwhawkins/fix_readme_markup
perrygeo Nov 6, 2018
a44b46d
catch fiona driver error
perrygeo Nov 26, 2018
221b47c
bump version
perrygeo Nov 26, 2018
7e3dc61
fixing issue where fiona DriverError was unhandled for string_type fe…
rhodges Mar 9, 2019
3e30d36
updates for pyt4est
perrygeo Mar 9, 2019
e0c4c83
merge pull 181
perrygeo Mar 9, 2019
f2581a5
Merge pull request #181 from rhodges/master
perrygeo Mar 9, 2019
43dc95d
JSONDecodeError isnt available in older python
perrygeo Mar 9, 2019
56486fd
py27 bytes
perrygeo Mar 9, 2019
910455c
Merge pull request #176 from perrygeo/fix-build
perrygeo Mar 9, 2019
9b9d373
Updated method calls for numpy v1.16
Zeitsperre Apr 11, 2019
af1a256
Added entry for newest numpy testing
Zeitsperre Apr 26, 2019
3960dba
hotfix
Zeitsperre Apr 26, 2019
4c1973f
hotfix (2)
Zeitsperre Apr 26, 2019
41689a7
hotfix (3)
Zeitsperre Apr 26, 2019
c499b00
hotfix (4)
Zeitsperre Apr 26, 2019
71e260a
exception handling
Zeitsperre Jun 7, 2019
1db2a33
Proposition to give access to geometry properties within the user-def…
Jun 15, 2019
55ed2c4
Merge pull request #184 from Zeitsperre/master
perrygeo Jun 15, 2019
92dc9de
adding test unit for functionality to access geometry properties for …
Jun 15, 2019
8a960e2
Merge pull request #193 from giplessis/master
perrygeo Jun 17, 2019
07e780a
Take into account per dataset mask
drnextgis Oct 15, 2019
96a2d67
Remove Python 3.4 from matrix
drnextgis Oct 15, 2019
f1d94b4
Add test for read_features
drnextgis Oct 15, 2019
ee49927
Merge pull request #198 from drnextgis/issue#197
perrygeo Nov 10, 2019
5dc65f4
remove python2 tests, add 3.7
perrygeo Nov 10, 2019
53bc453
add python 3.8
perrygeo Nov 10, 2019
e2c93df
Add support return statement to zone_func
drnextgis Dec 1, 2019
80bc1eb
One more test for read_features to increase coverage
drnextgis Dec 1, 2019
bbc5052
Merge pull request #203 from drnextgis/zone_func
perrygeo Dec 9, 2019
f967c1d
bump version to 0.14
perrygeo Dec 10, 2019
c8f0780
changed order of affine multiplication
Jwely Feb 25, 2020
00af862
Merge branch 'righ_multiplication_201'
Jwely Feb 25, 2020
a913471
Do not create array with ones, and then multiply value by nodata. In…
Feb 26, 2020
853a0c3
Merge pull request #213 from yyu1/optimization
perrygeo Feb 29, 2020
55dc7fb
chore: import collections.abc
hawkaa May 14, 2020
4319774
chore: left multiplication for rasterio
hawkaa May 14, 2020
ef043bb
Merge pull request #211 from Jwely/master
perrygeo May 14, 2020
646195e
release
perrygeo Jul 11, 2020
88c6d53
Merge pull request #220 from perrygeo/0.15.0
perrygeo Jul 11, 2020
9ae7239
specify pytest version
perrygeo Jul 11, 2020
0976fd5
python 3.5 is now deprecated
perrygeo Oct 2, 2020
3a6f0cb
Merge pull request #200 from perrygeo/python-versions
perrygeo Oct 2, 2020
aea6ac3
Update readme examples with slope raster, geojson points
perrygeo Oct 2, 2020
99ecafc
Merge pull request #217 from hawkaa/hakon/abc
perrygeo Oct 2, 2020
b2b0520
attempt to preserve 2.7 compatibility
perrygeo Oct 2, 2020
ceb0df2
Merge pull request #226 from perrygeo/abc
perrygeo Oct 2, 2020
c375094
Allow toggling off boundless reading
Oct 19, 2020
0622fd7
Merge pull request #228 from AsgerPetersen/boundless
perrygeo Nov 24, 2020
aac58a3
set dtype in new array creation
sdtaylor Jan 30, 2021
2cef998
drop np.asscalar for np.ndarray.item
sdtaylor Jan 30, 2021
cc2a005
drop depreciated to_wkt
sdtaylor Jan 30, 2021
2734e3a
Merge pull request #235 from sdtaylor/set_dtype
perrygeo Jan 31, 2021
c02901b
Merge pull request #236 from sdtaylor/fix_warnings
perrygeo Jan 31, 2021
2c254a6
update comment, rm runtime assertion
perrygeo Jan 31, 2021
5c589b4
use a standard bool flag on sequence to keep default to False
perrygeo Jan 31, 2021
ef45005
ignore UserWarnings, error on everything else, catch deprecated
perrygeo Jan 31, 2021
042b479
add github actions workflow, first attempt
perrygeo Jan 31, 2021
6fce3ae
no travis
perrygeo Jan 31, 2021
0a19bc6
github actions badges
perrygeo Jan 31, 2021
6f361df
fix link
perrygeo Jan 31, 2021
87f64a2
Merge pull request #237 from perrygeo/warning-hunt
perrygeo Jan 31, 2021
c08ccc8
Update README, typo
perrygeo Jan 31, 2021
3d7da54
Update issue templates
perrygeo Jan 31, 2021
50963b1
Update bug_report.md
perrygeo Jan 31, 2021
aa4130e
update setup.py with supported python versions, fixes #240
perrygeo Mar 24, 2021
96f5ee8
typo fix
jsta Oct 12, 2021
1d612b6
Update main.py
Malichmal Oct 28, 2021
9f2dcf7
Merge pull request #247 from jsta/jsta_typofix
perrygeo Oct 29, 2021
f41f5f3
Merge pull request #249 from Malichmal/patch-1
perrygeo Oct 29, 2021
57f49af
TODOs for additional test cases
perrygeo Oct 29, 2021
d4f2abe
remove py2 compat
perrygeo Oct 29, 2021
b9897d9
update geom_xys to avoid array interface
perrygeo Oct 29, 2021
e9e5e3e
testfix: close the polygon
perrygeo Oct 29, 2021
2981e8c
use equals_exact
perrygeo Oct 29, 2021
43028de
bump version
perrygeo Oct 29, 2021
ade5936
changes for 0.16.0
perrygeo Oct 29, 2021
75d6ef0
Merge pull request #250 from perrygeo/pre-0-16
perrygeo Oct 29, 2021
5736ca0
docs: Fix a few typos
timgates42 Nov 28, 2021
5da3110
Merge pull request #253 from timgates42/bugfix_typos
perrygeo Nov 28, 2021
e95694a
Fix 64 bit platform test performance regression
theroggy Jun 3, 2022
dd2fd03
Remove alternative 64 bit detections
theroggy Jun 3, 2022
04770e8
Make test less strict on windows
theroggy Jun 3, 2022
c5217b6
Merge pull request #258 from theroggy/Fix-prformance-regression-in-0.…
perrygeo Jul 21, 2022
a8b78fe
remove perf test which can change depending on environment
perrygeo Jul 21, 2022
678dc08
bump version
perrygeo Jul 21, 2022
83220a6
Merge pull request #260 from perrygeo/release-0.17
perrygeo Jul 21, 2022
7381b6d
PEP-518: specify minimum build system requirements with pyproject.toml
mwtoews Oct 5, 2022
d05f0db
Merge pull request #265 from mwtoews/pep-518
perrygeo Oct 18, 2022
79b9a88
Resolve shapely deprecation warnings; use pytest.importorskip
mwtoews Oct 19, 2022
31fbc49
add click, fixes #264
perrygeo Jan 15, 2023
80a10e7
Merge pull request #266 from mwtoews/shapely-dep
perrygeo Jan 15, 2023
e88e633
pin fiona to <1.9 until we can figure out breaking change
perrygeo Feb 2, 2023
16c6734
bump python versions
perrygeo Feb 2, 2023
92ae354
bump python versions
perrygeo Feb 2, 2023
d9c7a46
Merge pull request #275 from perrygeo/272-fiona-version
perrygeo Feb 2, 2023
46f7b96
bump version
perrygeo Feb 2, 2023
3d9aa48
turn up the python to 3.11
perrygeo Feb 2, 2023
cbdaaa5
Merge pull request #276 from perrygeo/0.17.1
perrygeo Feb 2, 2023
66f9e3f
Move project metadata to pyproject.toml
mwtoews Feb 5, 2023
c0e077b
Merge pull request #277 from mwtoews/pyproject-metadata
perrygeo Feb 9, 2023
7c44d41
apply black autoformatter
perrygeo Feb 16, 2023
25013d8
ignore black formatting for git blame
perrygeo Feb 16, 2023
5c7acb2
Merge pull request #278 from perrygeo/black-formatting
perrygeo Feb 16, 2023
92d9c3c
selectively use numpy dtype arg instead of casting all integer data
perrygeo Feb 16, 2023
930cc9e
globals hack to warn only once
perrygeo Feb 16, 2023
8babd0c
inherit from UserWarning
perrygeo Feb 16, 2023
7ae17a1
Merge pull request #279 from perrygeo/better-int-overflow-protection
perrygeo Feb 16, 2023
144144a
Merge pull request #280 from perrygeo/nodata-warn-once
perrygeo Feb 16, 2023
78ac30e
1.18.0
perrygeo Feb 16, 2023
4afc729
Python 3 upgrades
mwtoews Feb 23, 2023
62f6d62
Merge pull request #283 from mwtoews/pyupgrade
perrygeo Feb 23, 2023
d188eaf
Update CHANGELOG.txt
perrygeo Feb 23, 2023
f0e6ffb
Sort and absolufy imports
mwtoews Feb 28, 2023
57c99fa
Merge pull request #284 from mwtoews/misc
perrygeo Mar 1, 2023
9e06ace
Provide compatibility with Fiona 1.9
mwtoews Apr 2, 2023
52182ae
Merge pull request #287 from mwtoews/unpin-versions
perrygeo May 29, 2023
9ad8475
0.19.0
perrygeo May 29, 2023
8086a35
0.19.0
perrygeo May 29, 2023
e5c9e97
Add rv_array to custom functions
ericboucher Jun 28, 2023
12d5169
Add test
ericboucher Jun 28, 2023
5dac003
Merge pull request #290 from ericboucher/augment-custom-functions
perrygeo Oct 5, 2023
0bc96a0
ci: test against python 3.12, drop 3.7
perrygeo Aug 14, 2024
266e1fb
classifiers
perrygeo Aug 14, 2024
a2198c5
fix: cast percentiles to floats
perrygeo Aug 14, 2024
bc26a0d
only test old packages on old pythons
perrygeo Aug 14, 2024
23ae949
try using contains
perrygeo Aug 14, 2024
4f82d86
remove test for older dependencies
perrygeo Aug 14, 2024
76e3e56
Merge pull request #299 from perrygeo/mp/bump-python-312
perrygeo Aug 14, 2024
c5fd3b7
added tqdm to main.py in zonal_stats function. added tqdm in project.…
jeronimoluza Sep 19, 2024
5003d3c
added try to import tqdm and raising valueerror if tqdm is not instal…
jeronimoluza Sep 26, 2024
830bcac
Merge pull request #300 from jeronimoluza/progress_bar
perrygeo Sep 27, 2024
64885c5
catch ValueError too
perrygeo Sep 27, 2024
05c98d5
pin geopandas
perrygeo Sep 27, 2024
2fc300f
bump minimum python to 3.9
perrygeo Sep 27, 2024
7ac1c22
Merge pull request #301 from perrygeo/mp/fiona1.10
perrygeo Sep 27, 2024
7d5e5d3
0.20.0
perrygeo Sep 27, 2024
6a2769a
Merge pull request #302 from perrygeo/release/0.20
perrygeo Sep 27, 2024
11e9f02
fix the bug when progress = True
abovzv Dec 16, 2024
df579d4
Use hatchling build-backend, set minimum Python 3.9
mwtoews Aug 24, 2025
d024c53
Allow path-like objects for vector source; use Path for tests
mwtoews Aug 25, 2025
6c092d5
Merge pull request #308 from mwtoews/use-pathlike
perrygeo Sep 2, 2025
ac8689f
Merge branch 'master' into min-py39
perrygeo Sep 2, 2025
c620d12
Merge pull request #306 from mwtoews/min-py39
perrygeo Sep 2, 2025
4f67dfd
Merge pull request #304 from abovzv/abovzv/fix-generator
perrygeo Sep 2, 2025
736bd9b
ignore the uv.lock file for now
Sep 2, 2025
b28c153
Merge pull request #309 from perrygeo/ignore-uv-lock
perrygeo Sep 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# When making commits that are strictly formatting/style changes, add the
# commit hash here, so git blame can ignore the change.
#
# For more details, see:
# https://git-scm.com/docs/git-config#Documentation/git-config.txt-blameignoreRevsFile

7c44d41878b36b6f058ba448a4762757c3b4c0da # initial autoformat with black
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Bug report
about: Create a report to help us improve python-rasterstats
title: ""
labels: ''
assignees: ''

---

Welcome to the `python-rasterstats` issue tracker. Thanks for putting together a bug report! By following the template below, we'll be better able to reproduce the problem on our end.

If you don't have a bug specifically but a general support question, please visit https://gis.stackexchange.com/

**Describe the bug**
A clear and concise description of what the bug is. What you expected to happen vs. what did happen.

**To Reproduce**
Steps to reproduce the behavior:
1. How did you install rasterstats and its dependencies?
2. What datasets are necessary to reproduce the bug? Please provide links to example data if necessary.
3. What code is necessary to reproduce the bug? Provide the code directly below or provide links to it.

```python
# Code to reproduce the error
```

**Feature Requests**

`python-rasterstats` is not currently accepting any feature requests via the issue tracker. If you'd like to add a backwards-compatible feature, please open a pull request - it doesn't need to be 100% ready but should include a working proof-of-concept, tests, and should not break the existing API.
26 changes: 26 additions & 0 deletions .github/workflows/test-rasterstats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Rasterstats Python package

on:
pull_request:
push:
branches: [ $default-branch ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install pip --upgrade
python -m pip install -e ".[dev]"
- name: Test all packages
run: |
pytest
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ Vagrantfile
venv
.eggs
.cache

# no uv lockfile until this is fixed:
# https://github.com/astral-sh/uv/issues/10845
uv.lock
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

49 changes: 48 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
0.20.0
- Progress bar for interactive use (#300)
- Fixes to support Fiona 1.10 (#301)
- Drop Python 3.8 support, 3.9+ is the minimum version

0.19.0
- Drop Python 2 support, Python 3 style updates #283
- Sort imports #284
- Add support for Fiona>1.9 #287

0.18.0
- Move project metadata to pyproject.toml #277
- Black formatting #278
- Don't cast integers to int64, use numpy accumulator dtype #279
- Warn about nodata only once, io.NodataWarning type #280

0.17.1
- Fixes to keep up with recent versions of dependencies: #275 fiona, #266 shapely, #264 click
- Added a pyproject.toml #265
- Added CI testing for python 3.7 through 3.11

0.17.0
- Fix performance regression due to platform.architecture performance #258

0.16.0
- Fix deprecation warning with shapely 1.8+ #250

0.15.0
- Fix deprecation warning with Affine #211
- Avoid unnecessary memory copy operation #213

0.14.0
- Add support return statement to zone_func #203
- Take into account per dataset mask #198
- Accessing geometry properties for user-defined stats #193
- Updated method calls for numpy v1.16 #184

0.13.1
- Bug fix for io.read_features with Fiona 1.8+

0.13.0
- Require Rasterio>=1.0
- Fix buffer logic for boxify_points (#171)

0.12.1
- Cast all integer data to int64 if we're on a 64 bit platform (#159)

0.12.0
- zone_func argument to apply a function to the masked array before computing stats
- support shapely 1.6 exceptions
Expand All @@ -21,7 +68,7 @@
0.10.0
- Added a generator variant of zonal_stats (gen_zonal_stats) and point_query
(gen_point_query) which yield results instead of returning a list
- Dependency on cligj to standardize the geojson input/output args and opts
- Dependency on cligj to standardize the geojson input/output args and opts
- Input/Output can be geojson sequences; allows for stream processing

0.9.2
Expand Down
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

32 changes: 14 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ 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.
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?
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
Expand All @@ -25,39 +24,39 @@ mean elevation of each polygon.
Command Line Quick Start
------------------------

The command line interfaces to zonalstats and point_query
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 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']
>>> 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]
[756.6057470703125, 114.660084635416666]
[14.660084635416666, 56.60576171875]

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]
>>> point = {'type': 'Point', 'coordinates': (245309.0, 1000064.0)}
>>> point_query(point, "tests/data/slope.tif")
[74.09817594635244]


Issues
Expand All @@ -69,8 +68,5 @@ Find a bug? Report it via github issues by providing
- 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
.. |BuildStatus| image:: https://github.com/perrygeo/python-rasterstats/workflows/Rasterstats%20Python%20package/badge.svg
.. _BuildStatus: https://github.com/perrygeo/python-rasterstats/actions
4 changes: 2 additions & 2 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ for performing zonal statistics and point_queries at the command line.
Example
-----------

In the following examples we use a polygon shapefile representing countries (``countries.shp``) and a raster digitial elevation model (``dem.tif``). The data are assumed to be in the same spatial reference system.
In the following examples we use a polygon shapefile representing countries (``countries.shp``) and a raster digital elevation model (``dem.tif``). The data are assumed to be in the same spatial reference system.

GeoJSON inputs
^^^^^^^^^^^^^^
Expand All @@ -97,7 +97,7 @@ This will print the GeoJSON Features to the terminal (stdout) with Features like

{"type": Feature, "geometry": {...} ,"properties": {...}}

We'll use unix pipes to pass this data directly into our zonal stats command without an intemediate file.
We'll use unix pipes to pass this data directly into our zonal stats command without an intermediate file.

Specifying the Raster
^^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading