geoarrow-c

0.3.1 · active · verified Thu Apr 16

geoarrow-c provides Python bindings to the GeoArrow C and C++ implementation, enabling a geospatial type system and generic coordinate-shuffling. It supports Well-Known Binary (WKB), Well-Known Text (ISO), and GeoArrow encodings as Arrow extension types. The library is currently at version 0.3.1 and primarily serves as a low-level dependency for higher-level Python libraries like `geoarrow-python`. Its release cadence follows updates to the GeoArrow specification and its underlying C/C++ implementation.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the recommended way to interact with GeoArrow data in Python using `geoarrow-pyarrow`, which leverages `geoarrow-c` internally. It includes a basic example of reading GeoArrow-encoded data. It also shows a minimal direct import of `geoarrow.c.lib` for low-level access, which is generally not needed by most users.

import geoarrow.pyarrow as ga
import pyarrow as pa
import urllib.request
import os

# Most users should interact with GeoArrow via geoarrow-pyarrow for higher-level operations.
# geoarrow-c works under the hood of geoarrow-pyarrow.

# Example: Reading a GeoArrow-enabled IPC file using geoarrow.pyarrow
# This requires geoarrow-pyarrow and pyarrow, which internally use geoarrow-c.
# Replace with a real URL or local path if needed.
url = os.environ.get('GEOARROW_SAMPLE_DATA_URL', 'https://raw.githubusercontent.com/geoarrow/geoarrow-data/v0.2.0/natural-earth/files/natural-earth_cities_wkb.arrows')

try:
    with urllib.request.urlopen(url) as f, pa.ipc.open_stream(f) as reader:
        table = reader.read_all()
        print("Successfully read GeoArrow data via geoarrow.pyarrow.")
        print(table.schema.field("geometry").type)
except Exception as e:
    print(f"Could not fetch or read sample data: {e}")
    print("Ensure geoarrow-pyarrow and pyarrow are installed and the URL is accessible.")

# For direct, low-level interaction with geoarrow.c (less common for end-users):
from geoarrow.c import lib
print(f"geoarrow.c library loaded: {lib.__name__}")
# Further usage of `lib` involves Arrow C Data interface specifics, often via ctypes.

view raw JSON →