Pyogrio: Vectorized Spatial Vector File I/O

0.12.1 · active · verified Mon Apr 06

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.

Warnings

Install

Imports

Quickstart

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

import geopandas as gpd
from pyogrio import read_dataframe, write_dataframe
from shapely.geometry import Point
import os

# Create a dummy GeoDataFrame
data = {'name': ['Location A', 'Location B'], 'value': [10, 20]}
geometry = [Point(1, 1), Point(2, 2)]
gdf = gpd.GeoDataFrame(data, geometry=geometry, crs="EPSG:4326")

# Define output path
output_file = "my_geodata.gpkg"

# Write GeoDataFrame to a GeoPackage file
print(f"Writing data to {output_file}...")
write_dataframe(gdf, output_file, driver="GPKG", layer="my_points")
print("Write complete.")

# Read GeoDataFrame from the GeoPackage file
print(f"Reading data from {output_file}...")
read_gdf = read_dataframe(output_file, layer="my_points")
print("Read complete.")
print(read_gdf)

# Clean up the created file
# os.remove(output_file)
# print(f"Cleaned up {output_file}.")

view raw JSON →