Expand description
§pyo3-geoarrow
PyO3 bindings for GeoArrow types, enabling seamless integration between Rust’s GeoArrow implementation and Python.
This crate provides Python-compatible wrappers around GeoArrow data structures, allowing Python code to efficiently work with and share geospatial data in the GeoArrow format through the Arrow C Data Interface (using the Arrow PyCapsule Interface) without data copies.
§Features
- Zero-copy data exchange: Use Arrow’s C Data Interface for efficient memory sharing between Rust and Python.
- GeoArrow types: Python bindings for GeoArrow geometry arrays, scalars, and metadata.
- Type safety: Strongly-typed wrappers that preserve GeoArrow’s type system in Python.
- FFI support: Import and export GeoArrow data to/from Python using the Arrow PyCapsule Interface.
§Core Types
PyGeoArray: Python wrapper for GeoArrow geometry arraysPyGeoChunkedArray: Python wrapper for chunked GeoArrow geometry arraysPyGeoArrayReader: Python wrapper for streaming array readersPyGeoScalar: Python wrapper for GeoArrow scalar geometriesPyGeoType: Python wrapper for GeoArrow data typesPyCrs: Python wrapper for coordinate reference system representation
§Usage
This crate is primarily intended for use by Python binding developers who need to interoperate with GeoArrow data in Python. It is also used internally by the geoarrow-rust-* Python packages.
use std::sync::Arc;
use pyo3::prelude::*;
use pyo3_geoarrow::PyGeoArray;
use geoarrow_array::GeoArrowArray;
#[pyfunction]
fn process_geometry(py: Python, array: PyGeoArray) -> PyResult<PyGeoArray> {
// Access the underlying GeoArrow array
let inner: Arc<dyn GeoArrowArray> = array.into_inner();
// Perform operations...
Ok(PyGeoArray::new(inner))
}§Integration with Arrow
This crate implements the Arrow PyCapsule Interface, allowing GeoArrow objects to be exchanged with any Python library that supports Arrow, including:
- PyArrow
- Polars (once they support extension types)
- GeoPandas (via PyArrow)
- DuckDB
§Dependencies
This crate builds on:
pyo3: Python bindings for Rustpyo3-arrow: Arrow integration for PyO3geoarrow-array: Core GeoArrow array typesgeoarrow-schema: GeoArrow type system and metadata
Re-exports§
pub use data_type::PyGeoType;
Modules§
- data_
type - GeoArrow data type definitions and constructors.
- input
- Input types for accepting GeoArrow data from Python.
Structs§
- PyCoord
Buffer - Python wrapper for a GeoArrow coordinate buffer.
- PyCrs
- Python wrapper for a coordinate reference system (CRS).
- PyEdges
- Python wrapper for GeoArrow edge interpolation type.
- PyGeo
Array - Python wrapper for a GeoArrow geometry array.
- PyGeo
Array Reader - Python wrapper for a GeoArrow array reader (stream).
- PyGeo
Chunked Array - Python wrapper for a chunked GeoArrow geometry array.
- PyGeo
Scalar - Python wrapper for a GeoArrow scalar geometry.
- PyOffset
Buffer - Python wrapper for an Arrow offset buffer.
- PyprojCRS
Transform - An implementation of
CrsTransformusing pyproj.
Enums§
- PyCoord
Type - Python wrapper for GeoArrow coordinate type.
- PyDimension
- Python wrapper for GeoArrow coordinate dimension.
- PyGeo
Arrow Error - Error type for GeoArrow operations in Python bindings.
Type Aliases§
- PyGeo
Arrow Result - Result type for GeoArrow operations that may fail.