Pyogrio provides fast, bulk-oriented read and write access to GDAL/OGR vector data sources such as ESRI Shapefile, GeoPackage, GeoJSON, and FlatGeobuf. It significantly optimizes performance for geospatial data operations by leveraging pre-compiled GDAL/OGR bindings, thereby minimizing Python data type conversions. The library is actively maintained, with frequent releases that may include breaking changes between major minor versions. The current stable version is 0.12.1.
pip install pyogrioVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic GeoPandas GeoDataFrame, write it to a GeoPackage file using `pyogrio.write_dataframe`, and then read the data back into a GeoDataFrame using `pyogrio.read_dataframe`.
Update your code to expect `dict` or `list` types for JSON columns read from data sources.
Ensure your environment has GDAL 3.6 or a newer compatible version installed. Conda-forge installations typically handle this dependency.
Check the GDAL version Pyogrio is using via `pyogrio.__gdal_version_string__`. If conflicts arise, consider uninstalling then reinstalling Fiona with `--no-binary fiona` (e.g., `pip uninstall fiona; pip install fiona --no-binary fiona`) or use a conda-forge environment for consistent GDAL versions.
To retain original offsets or convert datetimes to strings, use the `datetime_as_string=True` or `mixed_offsets_as_utc=False` parameters in `read_dataframe`.
Upgrade macOS to version 12+ or follow the instructions for building Pyogrio from source if on an older OS.
Install `pyarrow` (`pip install pyarrow`) and ensure your GDAL version meets the minimum requirements (3.6 for reading, 3.8 for writing).
Ensure that the data types in your GeoDataFrame columns are compatible with the target OGR driver's schema before writing. Convert incompatible types (e.g., lists, tuples) to supported formats (e.g., strings) if necessary.
Install `geopandas` using `pip install geopandas` or via your package manager (e.g., `conda install geopandas -c conda-forge`).
Install GDAL development libraries and headers appropriate for your operating system. For Alpine, use `apk add gdal-dev`. For Debian/Ubuntu, use `apt install libgdal-dev`. For Conda environments, use `conda install gdal`.
Ensure GDAL/OGR and its development libraries are installed on your system before installing pyogrio. For Debian/Ubuntu: `sudo apt-get update && sudo apt-get install libgdal-dev gdal-bin`. For Conda: `conda install -c conda-forge pyogrio gdal`.
Verify that the file path is correct, the file exists at that location, and that your program has read permissions for both the file and the directory.
When writing to a Shapefile, ensure your GeoDataFrame contains only one layer. For multi-layer data, use a format that supports it, such as GeoPackage (`.gpkg`), FlatGeobuf (`.fgb`), or create separate Shapefiles for each layer.
Validate and clean your geometries before writing; ensure all entries in the geometry column are valid shapely objects, e.g., `df.geometry = df.geometry.apply(lambda geom: geom.buffer(0) if geom and not geom.is_valid else geom)` or `df.geometry = shapely.make_valid(df.geometry)`.