Python objects and dataframe operations#

This reference distinguishes eager dataframes, deferred plans and query results. The package’s literal export list and declarations are in cugeo.geometry. Exact dataframe member signatures are in the deferred and eager declarations.

Choose an object#

Purpose

Public names

Work and result

Describe or read a file

Table, table_from_file, scan_file, read_file

A Table describes a source. scan_file returns a deferred LazyFrame. read_file immediately returns an eager GeoDataFrame.

Register in-memory inputs

RegisteredTable, table_from_arrow, table_from_cudf

Register a producer for queries. Ownership depends on the copy choice.

Work eagerly

GeoDataFrame, GeoSeries, sjoin, sjoin_nearest

Operate on eager containers. Check the supported profile for the operands and operation.

Build a deferred query

LazyFrame, LazyGrouped, ColumnExpr

Build a plan and collect it to execute.

Run SQL or read chunks

sql, sql_chunked, Result, ChunkedResultReader

Return a result or a reader of result chunks.

Manage and prepare work

Session, PreparedGeometry, PreparedGeometryStats, prepare_geometry

Manage query resources and reuse a prepared Parquet geometry column.

Diagnose and configure

QueryError, NATIVE_STATUS, BuildIdentity, BuildComponent, CudaSdkIdentity, build_identity, set_device_reserve_policy

Inspect errors or build identity and configure the device reserve policy.

table_from_file(path, *, format=None, options=None) snapshots a file description without reading it. Table.path and Table.format describe the source. Table.options returns a fresh copy of its options. read_file(path, *, columns=None, geometry=None, active_geometry=None, format=None, options=None, session=None) reads immediately. Projected column names must be unique and exact. Source occurrences receive a new cuDF RangeIndex.

Session.prepare_geometry(table, *, geometry) accepts a Parquet Table and a geometry column name. It prepares a session object without reading the column immediately. Session.table_from_arrow(obj, *, geometry=None, copy=False) uploads host batches or borrows a single CUDA batch when eligible. Session.table_from_cudf(frame, *, copy, producer_stream=None) requires an explicit Boolean copy choice. See passing inputs and results between Python libraries for producer lifetime and export choices.

Eager frames and series#

GeoDataFrame.from_arrow constructs an eager frame. geometry and active_geometry_name identify the active geometry. set_geometry selects it and set_crs sets its CRS metadata. The frame exposes schema, columns, index, indexing, take, dropna, drop_duplicates and export methods. Geometry metadata and occurrence indexes are preserved within the checked profiles of these operations. Active-column delegates operate on the selected geometry.

GeoSeries provides measures such as area, length, bounds, count_coordinates, total_bounds and distance, predicates including intersects, within, contains, covers, covered_by, touches, disjoint and dwithin, and constructions such as centroid, envelope and buffer. It also exposes geometry state, row selection and exports. Check the declaration and supported operand, CRS, argument and result profile for the particular operation.

Eager spatial joins#

The eager method GeoDataFrame.sjoin(df, how='inner', predicate='intersects', lsuffix='left', rsuffix='right', **kwargs) has its own admission rules and producer requirements, including the qualified pylibcudf producer. Do not assume that its predicate support matches deferred joins or that either interface transforms coordinates automatically.

Deferred frames and joins#

LazyFrame.set_geometry, select, filter, sjoin and groupby retain a plan. collect executes it and returns a Result. collect_chunked returns a ChunkedResultReader. A ColumnExpr represents a scoped expression in that plan.

LazyFrame.sjoin(right, *, how='inner', predicate='intersects', lsuffix='left', rsuffix='right') joins the active geometries and retains left columns and right attributes as an unordered bag.

Option

Accepted planning values

how

inner, left

predicate

intersects, contains, within, covers, covered_by, touches

Suffixes

Nonempty strings without NUL

right, full and dwithin are recognized capability refusals. Unrecognized values are invalid. Admission of an option does not guarantee that every runtime geometry shape is supported. The planner tests cover both operand orientations and collisions: suffixes distinguish overlapping labels while expressions retain their input lineage. See the join planner tests for the checked fixtures.

Results and destinations#

Result.columns, types, type_metadata, schema and len(result) read metadata without copying result data. Together they identify output labels, SQL types, representation and units. rows copies to the host on first access. NULL becomes None, geometry and bytea become bytes, arbitrary numeric values remain lossless text, and temporal values are integer ticks or days.

Destination

Method

Placement and conditions

Python values

rows

Host row tuples, materialized lazily.

Arrow

to_arrow()

Independently owned host PyArrow table.

pandas

to_pandas()

Host ArrowDtype columns with field metadata. Labels must be unique.

GeoPandas

to_geopandas(geometry=None)

Host GeoDataFrame for qualified geometry layouts and selector conditions.

cuDF

to_cudf()

Device Arrow export. Refuses geometry, bytea, arbitrary-precision numeric and duplicate labels.

A geometry value can therefore appear as bytes in rows while the same result is refused by to_cudf. For device consumers retaining an Arrow export, see device buffer ordering and release.

ChunkedResultReader exposes the result schema and streamed state. has_next() computes the next chunk when needed. read_chunk() returns a Result, and iteration yields chunks in order. close() cancels remaining work. Chunks already read remain valid. A nonstreamed result is returned as one whole chunk and must fit in GPU memory.

Generated export index#

The index follows the literal public exports in the Python source. Function signatures preserve parameter names, defaults, and annotations. The binding column identifies re-exports and imported definitions. Runtime route conditions belong with each operation.

cugeo.geometry#

Export

Declaration

Binding

GeoDataFrame

Class

cugeo.geometry._eager.GeoDataFrame

GeoSeries

Class

cugeo.geometry._eager.GeoSeries

sjoin

sjoin(left_df, right_df, how='inner', predicate='intersects', lsuffix='left', rsuffix='right', distance=None, on_attribute=None, **kwargs)

cugeo.geometry._eager.sjoin

sjoin_nearest

sjoin_nearest(left_df, right_df, how='inner', max_distance=None, lsuffix='left', rsuffix='right', distance_col=None, exclusive=False)

cugeo.geometry._eager.sjoin_nearest

LazyFrame

Class

cugeo.geometry._dataframe.LazyFrame

LazyGrouped

Class

cugeo.geometry._dataframe.LazyGrouped

ColumnExpr

Class

cugeo.geometry._dataframe.ColumnExpr

Table

Class

—

PreparedGeometry

Class

—

PreparedGeometryStats

Class

—

RegisteredTable

Class

—

Result

Class

—

ChunkedResultReader

Class

—

QueryError

Imported binding

cugeo.geometry._rust.QueryError

NATIVE_STATUS

Attribute

—

Session

Class

—

table_from_file

table_from_file(path, *, format=None, options=None) -> Table

—

scan_file

scan_file(path, *, geometry, format=None, options=None) -> LazyFrame

—

read_file

read_file(path, *, columns=None, geometry=None, active_geometry=None, format=None, options=None, session=None)

—

prepare_geometry

prepare_geometry(table, *, geometry, device: int=0) -> PreparedGeometry

—

table_from_arrow

table_from_arrow(obj, *, geometry=None, copy=False, device: int=0) -> RegisteredTable

—

table_from_cudf

table_from_cudf(frame, *, copy, producer_stream=None, device: int=0) -> RegisteredTable

—

sql

sql(text: str, *, tables: Mapping, device: int=0, geometry_encoding: str='auto') -> Result

—

sql_chunked

sql_chunked(text: str, *, tables: Mapping, device: int=0, chunk_read_limit: int=0, geometry_encoding: str='auto') -> ChunkedResultReader

—

BuildIdentity

Class

cugeo.geometry._build_identity.BuildIdentity

BuildComponent

Class

cugeo.geometry._build_identity.BuildComponent

CudaSdkIdentity

Class

cugeo.geometry._build_identity.CudaSdkIdentity

build_identity

build_identity() -> BuildIdentity

cugeo.geometry._build_identity.build_identity

set_device_reserve_policy

set_device_reserve_policy(policy: str) -> None

—

__version__

Attribute

—

Generated direct class declarations#

These entries list public methods declared on the class. Source signatures may show a receiver parameter. Inherited methods and generated constructors follow the class or external binding named in the export index.

cugeo.geometry.BuildIdentity#

  • component(self, name: str) -> BuildComponent

  • to_dict(self) -> dict

cugeo.geometry.ChunkedResultReader#

  • __init__(self, native)

  • columns — property

  • types — property

  • type_metadata — property

  • schema — property

  • streamed — property

  • closed — property

  • has_next(self) -> bool

  • read_chunk(self) -> Result

  • close(self)

cugeo.geometry.ColumnExpr#

  • __init__(self, native)

  • area — property

  • is_null(self)

  • is_not_null(self)

cugeo.geometry.GeoDataFrame#

  • __init__(self)

  • from_arrow(cls, obj, *, geometry, active_geometry=None, index=None, session=None)

  • columns — property

  • index — property

  • active_geometry_name — property

  • crs — property

  • schema — property

  • geometry — property

  • set_geometry(self, label)

  • set_crs(self, crs=None, epsg=None, inplace=False, allow_override=False)

  • covered_by(self, other, align=None)

  • touches(self, other, align=None)

  • sjoin(self, df, how='inner', predicate='intersects', lsuffix='left', rsuffix='right', **kwargs)

  • sjoin_nearest(self, right, how='inner', max_distance=None, lsuffix='left', rsuffix='right', distance_col=None, exclusive=False)

  • disjoint(self, other, align=None)

  • geom_type — property

  • count_coordinates(self)

  • total_bounds — property

  • is_empty — property

  • centroid — property

  • envelope — property

  • buffer(self, distance, resolution=16, cap_style='round', join_style='round', mitre_limit=5.0, single_sided=False, **kwargs)

  • dwithin(self, other, distance, align=None)

  • dropna(self, *, axis=0, how=_NO_DEFAULT, thresh=_NO_DEFAULT, subset=None, inplace=False, ignore_index=False)

  • drop_duplicates(self, subset=None, *, keep='first', inplace=False, ignore_index=False)

  • take(self, positions)

  • to_arrow(self)

  • to_geopandas(self)

cugeo.geometry.GeoSeries#

  • __init__(self)

  • name — property

  • index — property

  • crs — property

  • schema — property

  • set_crs(self, crs=None, epsg=None, inplace=False, allow_override=False)

  • geom_type — property

  • count_coordinates(self)

  • is_empty — property

  • area — property

  • centroid — property

  • envelope — property

  • buffer(self, distance, resolution=16, cap_style='round', join_style='round', mitre_limit=5.0, single_sided=False, **kwargs)

  • length — property

  • bounds — property

  • intersects(self, other, align=None)

  • total_bounds — property

  • within(self, other, align=None)

  • contains(self, other, align=None)

  • covers(self, other, align=None)

  • covered_by(self, other, align=None)

  • touches(self, other, align=None)

  • disjoint(self, other, align=None)

  • distance(self, other, align=None)

  • dwithin(self, other, distance, align=None)

  • take(self, positions)

  • isna(self)

  • notna(self)

  • dropna(self, *, axis=0, inplace=False, how=None, ignore_index=False)

  • drop_duplicates(self, *, keep='first', inplace=False, ignore_index=False)

  • to_arrow(self)

  • to_geopandas(self)

cugeo.geometry.LazyFrame#

  • __init__(self, source)

  • geometry — property

  • set_geometry(self, label)

  • select(self, columns=(), **named)

  • filter(self, condition)

  • sjoin(self, right, *, how='inner', predicate='intersects', lsuffix='left', rsuffix='right')

  • groupby(self, keys, *, dropna=False, sort=False, as_index=False)

  • collect(self, *, session=None, device=None, geometry_encoding='auto')

  • collect_chunked(self, *, session=None, device=None, geometry_encoding='auto', chunk_read_limit=0)

cugeo.geometry.LazyGrouped#

  • __init__(self, native)

  • agg(self, **named)

  • size(self, *, name='rows')

cugeo.geometry.PreparedGeometry#

  • __init__(self, native, table, geometry, device)

  • table — property

  • geometry — property

  • device — property

  • stats(self)

  • release(self)

cugeo.geometry.RegisteredTable#

  • __init__(self, native)

  • device — property

  • row_count — property

  • owned_device_bytes — property

  • stats(self)

  • release(self)

cugeo.geometry.Result#

  • __init__(self, device)

  • columns — property

  • types — property

  • type_metadata — property

  • schema — property

  • rows — property

  • export(self, *, stream)

  • to_arrow(self)

  • to_pandas(self)

  • to_geopandas(self, geometry=None)

  • to_cudf(self)

cugeo.geometry.Session#

  • __init__(self, device=0, *, device_memory_limit=None, memory_resource=None, decimal_width='precision', device_reserve=None)

  • device — property

  • decimal_width — property

  • closed — property

  • retained_device_bytes — property

  • device_reservation — property

  • close(self)

  • sql(self, text: str, *, tables: Mapping, geometry_encoding: str='auto') -> Result

  • sql_chunked(self, text: str, *, tables: Mapping, chunk_read_limit: int=0, geometry_encoding: str='auto') -> ChunkedResultReader

  • prepare_geometry(self, table, *, geometry) -> PreparedGeometry

  • table_from_cudf(self, frame, *, copy, producer_stream=None) -> RegisteredTable

  • table_from_arrow(self, obj, *, geometry=None, copy=False) -> RegisteredTable

cugeo.geometry.Table#

  • __init__(self, path, *, format=None, options=None)

  • options — property

Generated class protocol declarations#

Class

Declaration

GeoDataFrame

__len__(self)

GeoDataFrame

__getitem__(self, key)

GeoSeries

__len__(self)

GeoSeries

__getitem__(self, mask)

LazyFrame

__getitem__(self, label)

ColumnExpr

__array_ufunc__(self, ufunc, method, *inputs, **kwargs)

RegisteredTable

__len__(self)

Result

__len__(self)

Result

__iter__(self)

Result

__arrow_c_schema__(self)

Result

__arrow_c_device_array__(self, requested_schema=None, **kwargs)

Result

__arrow_c_device_stream__(self, requested_schema=None, **kwargs)

Result

__arrow_c_stream__(self, requested_schema=None)

ChunkedResultReader

__iter__(self)

ChunkedResultReader

__next__(self) -> Result

ChunkedResultReader

__arrow_c_schema__(self)

ChunkedResultReader

__arrow_c_device_stream__(self, requested_schema=None, **kwargs)