[v0.21.0] pyogrio generator#314
Conversation
|
With $ uv run scripts/bench_engines.py 500000
Generating 500,000 random point features over slope.tif …
Wrote 65.7 MB → /var/folders/17/gt7fm_5j065bkp6_k04zfrn00000gn/T/tmpxsrljdmu.geojson
fiona : 4.539s (110,158 feat/s)
pyogrio: 22.134s (22,590 feat/s)
fiona is 4.88x faster |
|
with recent changes: $ uv run scripts/bench_engines.py 500000
Generating 500,000 random point features over slope.tif …
Wrote 65.7 MB → /var/folders/17/gt7fm_5j065bkp6_k04zfrn00000gn/T/tmpgmt3f3bx.geojson
fiona : 4.514s (110,767 feat/s)
/Users/matthew/projects/python-rasterstats/.venv/lib/python3.14/site-packages/pyogrio/raw.py:198:
RuntimeWarning: driver GeoJSON does not support open option USE_ARROW
return ogr_read(
pyogrio: 10.205s (48,997 feat/s)
fiona is 2.26x faster |
|
Now we're getting somewhere... uv run scripts/bench_engines.py 500000
Generating 500,000 random point features over slope.tif …
Wrote GeoJSON 65.7 MB → /var/folders/17/gt7fm_5j065bkp6_k04zfrn00000gn/T/tmp4dg3z8wh.geojson
Converting to GeoPackage via ogr2ogr …
Wrote GeoPackage 44.9 MB → /var/folders/17/gt7fm_5j065bkp6_k04zfrn00000gn/T/tmpwn09reve.gpkg
=== GeoJSON ===
fiona : 4.635s (107,868 feat/s)
pyogrio: 10.397s (48,089 feat/s)
fiona is 2.24x faster (GeoJSON)
=== GeoPackage ===
fiona : 2.858s (174,936 feat/s)
pyogrio: 2.050s (243,951 feat/s)
pyogrio is 1.39x faster (GeoPackage)Some formats get faster, some slower... |
|
|
|
The latest benchmark, fiona and pyogrio are working. The pyogrio generator is now performing well enough for me to use it as the default! uv run scripts/bench_engines.py
Generating 100,000 random point features over slope.tif …
Wrote GeoJSON 13.1 MB → /var/folders/17/gt7fm_5j065bkp6_k04zfrn00000gn/T/tmp_brzukhr.geojson
Converting to GeoPackage via ogr2ogr …
Wrote GeoPackage 9.0 MB → /var/folders/17/gt7fm_5j065bkp6_k04zfrn00000gn/T/tmp7ptsired.gpkg
Converting to Shapefile via ogr2ogr …
Wrote Shapefile 4.4 MB → /var/folders/17/gt7fm_5j065bkp6_k04zfrn00000gn/T/tmpa_uol1xl
Converting to FlatGeobuf via ogr2ogr …
Wrote FlatGeobuf 11.7 MB → /var/folders/17/gt7fm_5j065bkp6_k04zfrn00000gn/T/tmp2amhqcij.fgb
=== GeoJSON ===
fiona : 0.939s (106,504 feat/s)
pyogrio: 1.054s (94,915 feat/s)
fiona is 1.12x faster (GeoJSON)
=== GeoPackage ===
fiona : 0.553s (180,951 feat/s)
pyogrio: 0.416s (240,482 feat/s)
pyogrio is 1.33x faster (GeoPackage)
=== Shapefile ===
fiona : 0.654s (153,016 feat/s)
pyogrio: 0.441s (226,957 feat/s)
pyogrio is 1.48x faster (Shapefile)
=== FlatGeobuf ===
fiona : skip
pyogrio: 0.440s (227,337 feat/s)As the file size gets larger, pyogrio's advantage grows for most binary formats. For GeoJSON however, the opposite is true; large GeoJSON files get progressively slower with pyogrio. This is a fair tradeoff IMO - the assumption is that if you have large performance-sensitive data, you probably won't be using GeoJSON anyway. |
|
Thanks a lot for this! 😄 Our team was blocked from migrating to Python 3.14 due to using I also find it very amusing that this ticket, which implements Python 3.14 support, has ticket number 314. |
fionais a great library that worked well with our records-based iteration approach. However, recent releases don't have a Python 3.14 binary wheel which complicates installation for many users. Additionally several projects, notably geopandas, are switching topyogriofor bulk loading performance.This PR implements
pyogrioas the default rasterstats engine.pip install rasterstatswill includepyogrioby defaultpip install rasterstats[fiona]will let you specify theengine=fionaparameter if you need to keep the old behavior.engine=fionaif you absolutely must get top performance out of very large 50MB+ GeoJSONs.