Skip to content

Column Selection

polars_st.geom #

geom(name: str | Iterable[str] | None = None, *more_names: str) -> GeoExpr

Create a geometry column expression.

Alias for polars.col. If no name is given, the default from st.Config will be used.

Parameters:

  • name (str | Iterable[str] | None, default: None ) –

    The name or datatype of the geometry column(s) to represent. Accepts regular expression input. Regular expressions should start with ^ and end with $.

  • more_names (str, default: () ) –

    Additional names or datatypes of columns to represent, specified as positional arguments.

Examples:

Pass a single column name to represent that column:

>>> gdf = st.GeoSeries("geom", ["POINT(0 0)"]).to_frame()
>>> gdf.select(st.geom().st.to_wkt())
shape: (1, 1)
┌─────────────┐
│ geom        │
│ ---         │
│ str         │
╞═════════════╡
│ POINT (0 0) │
└─────────────┘

Call geom without a column name to use the default:

>>> gdf = st.GeoDataFrame([
...     "POINT(0 0)",
...     "POINT(1 2)",
... ])
>>> gdf.select(st.geom().st.union_all().st.to_wkt())
shape: (1, 1)
┌───────────────────────────┐
│ geometry                  │
│ ---                       │
│ str                       │
╞═══════════════════════════╡
│ MULTIPOINT ((0 0), (1 2)) │
└───────────────────────────┘

polars_st.element #

element() -> GeoExpr

Alias for polars.element.

Examples:

>>> gdf = st.GeoDataFrame([
...     "MULTIPOINT ((0 0), (1 2))"
... ])
>>> gdf.select(st.parts().list.eval(st.element().st.to_wkt()))
shape: (1, 1)
┌────────────────────────────────┐
│ geometry                       │
│ ---                            │
│ list[str]                      │
╞════════════════════════════════╡
│ ["POINT (0 0)", "POINT (1 2)"] │
└────────────────────────────────┘