snail.core package¶
- class snail.core.SplitStream¶
Bases:
pybind11_objectA stream of split geometries, readable through the Arrow PyCapsule stream interface, e.g. by pyarrow.RecordBatchReader or geopandas.GeoDataFrame.from_arrow. Each record batch holds a GeoArrow ‘geometry’ column of the pieces and a ‘parent’ column giving the index of the geometry each piece was split from.
- Attributes:
geometry_typeThe GeoArrow extension name of the pieces, e.g.
- property geometry_type¶
The GeoArrow extension name of the pieces, e.g. ‘geoarrow.linestring’
- snail.core.get_cell_indices(linestring: object, nrows: SupportsInt | SupportsIndex, ncols: SupportsInt | SupportsIndex, transform: collections.abc.Sequence[SupportsFloat | SupportsIndex]) tuple[int, int]¶
Get LineString cell indices in a grid
- snail.core.split_geometries(geometries: object, nrows: SupportsInt | SupportsIndex, ncols: SupportsInt | SupportsIndex, transform: collections.abc.Sequence[SupportsFloat | SupportsIndex], bounded: bool = False) snail.core.intersections.SplitStream¶
Split geometries of any type along a grid.
Takes geometries of any GeoArrow encoding, including geoarrow.wkb and multi-part types, from any object supporting the Arrow PyCapsule interface. Unlike split_linestrings and split_polygons it does not require the column to hold a single geometry type, so it can split a layer of mixed geometries - which only WKB can carry, since geopandas will not write a mixed frame as geoarrow-encoded at all.
Each geometry is handled on its own terms: LineStrings and Polygons are split, Points pass through unchanged, multi-part geometries are split part by part, and a GeometryCollection is split member by member. Every piece is attributed to the row it came from, whatever it came out of. An empty geometry comes back as itself.
Returns a SplitStream whose pieces are geoarrow.wkb.
- snail.core.split_linestring(linestring_py: object, nrows: SupportsInt | SupportsIndex, ncols: SupportsInt | SupportsIndex, transform: collections.abc.Sequence[SupportsFloat | SupportsIndex], bounded: bool = False) object¶
Split LineString along a grid, returning LineString pieces
- snail.core.split_linestrings(linestrings: object, nrows: SupportsInt | SupportsIndex, ncols: SupportsInt | SupportsIndex, transform: collections.abc.Sequence[SupportsFloat | SupportsIndex], bounded: bool = False) snail.core.intersections.SplitStream¶
Split LineStrings along a grid.
Takes geoarrow.linestring geometries from any object supporting the Arrow PyCapsule interface: a pyarrow ChunkedArray, Table or RecordBatchReader, a GeoParquet or Dataset reader, the result of GeoSeries.to_arrow(geometry_encoding=”geoarrow”), or a record batch stream with a GeoArrow geometry column.
Returns a SplitStream of the LineString pieces.
- snail.core.split_polygon(polygon: object, nrows: SupportsInt | SupportsIndex, ncols: SupportsInt | SupportsIndex, transform: collections.abc.Sequence[SupportsFloat | SupportsIndex]) object¶
Split Polygon along a grid, returning Polygon pieces
- snail.core.split_polygons(polygons: object, nrows: SupportsInt | SupportsIndex, ncols: SupportsInt | SupportsIndex, transform: collections.abc.Sequence[SupportsFloat | SupportsIndex]) snail.core.intersections.SplitStream¶
Split Polygons along a grid.
Takes geoarrow.polygon geometries, with coordinates interleaved or separated, from any object supporting the Arrow PyCapsule interface: a pyarrow ChunkedArray, Table or RecordBatchReader, a GeoParquet or Dataset reader, the result of GeoSeries.to_arrow(geometry_encoding=”geoarrow”), or a record batch stream with a GeoArrow geometry column.
Returns a SplitStream of the Polygon pieces.