Skip to content

Configuration

polars_st.Config #

Config(geometry_column: str | None = None)

Bases: ContextDecorator

Configuration object for polars-st.

Parameters:

  • geometry_column (str | None, default: None ) –

    Default geometry column name. Using None will reset this value to the built-in default "geometry".

Examples:

Use as a context manager:

>>> gdf = st.GeoSeries("my_geometry", ["POINT(1 2)"]).to_frame()
>>> with st.Config(geometry_column="my_geometry"):
...     x = gdf.select(st.x())
>>> x.schema
Schema([('my_geometry', Float64)])

Use as a context decorator:

>>> @st.Config(geometry_column="my_geometry")
... def get_my_bounds(gdf):
...     return gdf.select(st.bounds())
>>> gdf = st.GeoSeries("my_geometry", ["POINT(1 2)"]).to_frame()
>>> bounds = get_my_bounds(gdf)
>>> x.schema
Schema({'my_geometry': Array(Float64, shape=(4,))})

Use as a global configuration object:

>>> st.Config.set_geometry_column("my_geometry")
>>> gdf = st.GeoSeries(["POINT(1 2)"]).to_frame()
>>> gdf.schema
Schema([('my_geometry', Binary)])

set_geometry_column classmethod #

set_geometry_column(name: str | None = None) -> type[Self]

get_geometry_column classmethod #

get_geometry_column() -> str