Skip to content

Commit e1e5245

Browse files
authored
Merge pull request #314 from perrygeo/mp/pyogrio
[v0.21.0] pyogrio generator
2 parents e51b48a + 77b2218 commit e1e5245

13 files changed

Lines changed: 739 additions & 124 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Vagrantfile
1717
venv
1818
.eggs
1919
.cache
20+
.python-version
21+
*.lprof
2022

2123
# no uv lockfile until this is fixed:
2224
# https://github.com/astral-sh/uv/issues/10845

CHANGELOG.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
0.21.0
2+
- Replace fiona with pyogrio as the default vector io engine #314
3+
- Binary wheel support for python 3.14
4+
- Promises better performance. See improvements in PR.
5+
- Pass `engine=fiona` to use the old code path.
6+
- Vector file detection now also uses pyogrio, so driver discovery etc may have changed for edge cases.
7+
- fix bug in progress bar #304
8+
- build, tooling, and test improvements #306 #308 #309 #310
9+
110
0.20.0
211
- Progress bar for interactive use (#300)
312
- Fixes to support Fiona 1.10 (#301)

docs/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Quickstart
2222

2323
Install::
2424

25+
uv add rasterstats
26+
27+
Or with pip::
28+
2529
pip install rasterstats
2630

2731

docs/installation.rst

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
11
Installation
22
============
33

4-
Depends on libgdal, rasterio, fiona, shapely and numpy
4+
Depends on libgdal, rasterio, fiona, shapely and numpy.
55

6-
Using Ubuntu 14.04::
6+
Using ``uv`` (recommended)::
77

8-
sudo apt-get install python-numpy libgdal1h gdal-bin libgdal-dev
9-
pip install rasterstats
8+
uv add rasterstats
109

11-
Or homebrew on OS X::
10+
Or with pip::
1211

13-
brew install gdal
1412
pip install rasterstats
1513

16-
For Windows, follow the `rasterio installation <https://github.com/mapbox/rasterio#windows-1>`_ and then run::
14+
Platform-specific GDAL setup
15+
-----------------------------
1716

18-
pip install rasterstats
17+
**Ubuntu**::
18+
19+
sudo apt-get install libgdal-dev gdal-bin
20+
21+
then install rasterstats as above.
22+
23+
**macOS** (Homebrew)::
24+
25+
brew install gdal
26+
27+
then install rasterstats as above.
28+
29+
**Windows**: follow the `rasterio installation <https://github.com/mapbox/rasterio#windows-1>`_,
30+
then install rasterstats as above.
31+
32+
Tests
33+
-----
34+
35+
To run the python unit tests
1936

37+
uv run pytest

docs/manual.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,19 @@ while ``point_query`` gives us a list of raster values corresponding to each inp
4141
Vector Data Sources
4242
-------------------
4343
The most common use case is having vector data sources in a file such as an ESRI Shapefile or any
44-
other format supported by ``fiona``. The path to the file can be passed in directly as the first argument::
44+
other format supported by ``pyogrio``. The path to the file can be passed in directly as the first argument::
4545
4646
>>> zs = zonal_stats('tests/data/polygons.shp', 'tests/data/slope.tif')
4747

4848
If you have multi-layer sources, you can specify the ``layer`` by either name or index::
4949

5050
>>> zs = zonal_stats('tests/data', 'tests/data/slope.tif', layer="polygons")
5151

52+
If you have ``fiona`` installed and want to use it as the vector iteration engine
53+
instead of the default ``pyogrio``, you can optionally add ``engine='fiona'``
54+
55+
>>> zs = zonal_stats("tests/data/polygons.shp", "tests/data/slope.tif", engine="fiona")
56+
5257
In addition to the basic usage above, rasterstats supports other
5358
mechanisms of specifying vector geometries.
5459

@@ -294,5 +299,3 @@ command line tool, as well as GRASS's `r.statistics <https://grass.osgeo.org/gra
294299
They were suitable for offline analyses but were rather clunky to deploy in a large python application.
295300
In 2013, I implemented a proof-of-concept zonal stats function which eventually became ``rasterstats``. It has
296301
been in production in several large python web applications ever since, replacing the starspan wrapper `madrona.raster_stats <https://github.com/Ecotrust/madrona/blob/master/docs/raster_stats.rst>`_.
297-
298-

pyproject.toml

Lines changed: 53 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,64 @@
1+
# Note: code auto-formatted with `taplo fmt`
12
[build-system]
23
requires = ["hatchling"]
34
build-backend = "hatchling.build"
45

56
[project]
67
name = "rasterstats"
78
description = "Summarize geospatial raster datasets based on vector geometries"
8-
authors = [
9-
{name = "Matthew Perry", email = "perrygeo@gmail.com"},
10-
]
9+
authors = [{ name = "Matthew Perry", email = "perrygeo@gmail.com" }]
1110
readme = "README.rst"
12-
keywords = ["gis", "geospatial", "geographic", "raster", "vector", "zonal statistics"]
11+
keywords = [
12+
"gis",
13+
"geospatial",
14+
"geographic",
15+
"raster",
16+
"vector",
17+
"zonal statistics",
18+
]
1319
dynamic = ["version"]
14-
license = {text = "BSD-3-Clause"}
20+
license = { text = "BSD-3-Clause" }
1521
classifiers = [
16-
"Development Status :: 4 - Beta",
17-
"Intended Audience :: Developers",
18-
"Intended Audience :: Science/Research",
19-
"License :: OSI Approved :: BSD License",
20-
"Operating System :: OS Independent",
21-
"Programming Language :: Python :: 3",
22-
"Programming Language :: Python :: 3.9",
23-
"Programming Language :: Python :: 3.10",
24-
"Programming Language :: Python :: 3.11",
25-
"Programming Language :: Python :: 3.12",
26-
"Topic :: Utilities",
27-
"Topic :: Scientific/Engineering :: GIS",
22+
"Development Status :: 4 - Beta",
23+
"Intended Audience :: Developers",
24+
"Intended Audience :: Science/Research",
25+
"License :: OSI Approved :: BSD License",
26+
"Operating System :: OS Independent",
27+
"Programming Language :: Python :: 3",
28+
"Programming Language :: Python :: 3.9",
29+
"Programming Language :: Python :: 3.10",
30+
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
32+
"Programming Language :: Python :: 3.13",
33+
"Programming Language :: Python :: 3.14",
34+
"Topic :: Utilities",
35+
"Topic :: Scientific/Engineering :: GIS",
2836
]
2937
requires-python = ">=3.9"
3038
dependencies = [
31-
"affine",
32-
"click >7.1, !=8.2.1",
33-
"cligj >=0.4",
34-
"fiona",
35-
"numpy >=1.9",
36-
"rasterio >=1.0",
37-
"simplejson",
38-
"shapely",
39+
"affine",
40+
"click >7.1, !=8.2.1",
41+
"cligj >=0.4",
42+
"numpy >=1.9",
43+
"pyogrio",
44+
"rasterio >=1.0",
45+
"simplejson",
46+
"shapely",
3947
]
4048

4149
[project.optional-dependencies]
42-
progress = [
43-
"tqdm"
44-
]
45-
docs = [
46-
"numpydoc",
47-
"sphinx",
48-
"sphinx-rtd-theme",
49-
]
50+
progress = ["tqdm"]
51+
fiona = ["fiona"]
52+
docs = ["numpydoc", "sphinx", "sphinx-rtd-theme"]
5053
test = [
51-
"coverage",
52-
"geopandas",
53-
"pyshp >=1.1.4",
54-
"pytest >=4.6",
55-
"pytest-cov >=2.2.0",
56-
"simplejson",
57-
]
58-
dev = [
59-
"rasterstats[test]",
60-
"ruff",
61-
"twine",
54+
"coverage",
55+
"geopandas",
56+
"pyshp >=1.1.4",
57+
"pytest >=4.6",
58+
"pytest-cov >=2.2.0",
59+
"simplejson",
6260
]
61+
dev = ["rasterstats[test,fiona]", "ruff", "twine"]
6362

6463
[project.entry-points."rasterio.rio_plugins"]
6564
zonalstats = "rasterstats.cli:zonalstats"
@@ -73,31 +72,28 @@ Documentation = "https://pythonhosted.org/rasterstats/"
7372
only-include = ["src", "tests"]
7473

7574
[tool.pytest.ini_options]
76-
filterwarnings = [
77-
"error",
78-
"ignore::UserWarning",
79-
]
75+
filterwarnings = ["error", "ignore::UserWarning"]
8076
testpaths = ["tests"]
81-
# addopts = "--verbose -rf --ipdb --maxfail=1"
77+
addopts = "--verbose -rf --cov rasterstats --cov-report html"
8278

8379
[tool.setuptools.dynamic]
84-
version = {attr = "rasterstats._version.__version__"}
80+
version = { attr = "rasterstats._version.__version__" }
8581

8682
[tool.hatch.version]
8783
path = "src/rasterstats/_version.py"
8884

8985
[tool.ruff.lint]
9086
select = [
91-
"E", # pycodestyle
92-
"F", # Pyflakes
93-
"I", # isort
94-
"RUF", # Ruff-specific rules
95-
"UP", # pyupgrade
87+
"E", # pycodestyle
88+
"F", # Pyflakes
89+
"I", # isort
90+
"RUF", # Ruff-specific rules
91+
"UP", # pyupgrade
9692
]
9793
ignore = [
98-
"RUF005", # Consider iterable unpacking instead of concatenation
94+
"E501", # Disable: line too long
95+
"RUF005", # Disable: Consider iterable unpacking instead of concatenation
9996
]
10097

10198
[tool.ruff]
102-
# TODO: files in docs/notebooks/ use old versions and are incompatible with modern tools
10399
extend-exclude = ["*.ipynb"]

0 commit comments

Comments
 (0)