GeoExpr
polars_st.GeoExpr #
polars_st.GeoExprNameSpace #
polars_st.GeoExprNameSpace.geometry_type #
Return the type ID of each geometry.
- 0 = Unknown
- 1 = Point
- 2 = LineString
- 3 = Polygon
- 4 = MultiPoint
- 5 = MultiLineString
- 6 = MultiPolygon
- 7 = GeometryCollection
- 8 = CircularString
- 9 = CompoundCurve
- 10 = CurvePolygon
- 11 = MultiCurve
- 12 = MultiSurface
- 13 = Curve
- 14 = Surface
- 15 = PolyhedralSurface
- 16 = Tin
- 17 = Triangle
Examples:
polars_st.GeoExprNameSpace.dimensions #
Return the inherent dimensionality of each geometry.
The inherent dimension is 0 for points, 1 for linestrings and linearrings, and 2 for polygons. For geometrycollections it is the max of the containing elements.
Examples:
polars_st.GeoExprNameSpace.coordinate_dimension #
Return the coordinate dimension (2, 3 or 4) of each geometry.
polars_st.GeoExprNameSpace.minimum_clearance #
Return the geometry minimum clearance.
polars_st.GeoExprNameSpace.count_coordinates #
Return the number of coordinates in each geometry.
polars_st.GeoExprNameSpace.coordinates #
coordinates(output_dimension: Literal[2, 3] = 2) -> Expr
Return the coordinates of each geometry.
polars_st.GeoExprNameSpace.apply_coordinates #
apply_coordinates(transform: CoordinatesApply) -> GeoExpr
Replace the coordinates of each geometry with new ones.
polars_st.GeoExprNameSpace.exterior_ring #
exterior_ring() -> GeoExpr
Return the exterior ring of Polygon geometries.
polars_st.GeoExprNameSpace.interior_rings #
Return the list of interior rings for Polygon geometries.
polars_st.GeoExprNameSpace.count_interior_rings #
Return the number of interior rings in Polygon geometries.
polars_st.GeoExprNameSpace.get_interior_ring #
get_interior_ring(index: IntoIntegerExpr) -> GeoExpr
Return the nth ring of Polygon geometries.
polars_st.GeoExprNameSpace.count_geometries #
Return the number of parts in multipart geometries.
polars_st.GeoExprNameSpace.get_geometry #
get_geometry(index: IntoIntegerExpr) -> GeoExpr
Return the nth part of multipart geometries.
polars_st.GeoExprNameSpace.count_points #
Return the number of points in LineString geometries.
polars_st.GeoExprNameSpace.get_point #
get_point(index: IntoIntegerExpr) -> GeoExpr
Return the nth point of LineString geometries.
polars_st.GeoExprNameSpace.parts #
Return the list of parts for multipart geometries.
polars_st.GeoExprNameSpace.set_precision #
set_precision(
grid_size: IntoDecimalExpr,
mode: Literal["valid_output", "no_topo", "keep_collapsed"] = "valid_output",
) -> GeoExpr
Set the precision of each geometry to a certain grid size.
polars_st.GeoExprNameSpace.distance #
distance(other: IntoGeoExprColumn) -> Expr
Return the distance from each geometry to other.
polars_st.GeoExprNameSpace.hausdorff_distance #
hausdorff_distance(
other: IntoGeoExprColumn, densify: float | None = None
) -> Expr
Return the hausdorff distance from each geometry to other.
polars_st.GeoExprNameSpace.frechet_distance #
frechet_distance(
other: IntoGeoExprColumn, densify: float | None = None
) -> Expr
Return the frechet distance from each geometry to other.
polars_st.GeoExprNameSpace.set_srid #
set_srid(srid: IntoIntegerExpr) -> GeoExpr
Set the SRID of each geometry to a given value.
Parameters:
-
srid
(IntoIntegerExpr
) –The geometry new SRID
polars_st.GeoExprNameSpace.to_srid #
Transform the coordinates of each geometry into a new CRS.
Parameters:
-
srid
(int
) –The srid code of the new CRS
polars_st.GeoExprNameSpace.to_wkt #
to_wkt(
rounding_precision: int | None = 6,
trim: bool = True,
output_dimension: Literal[2, 3, 4] = 3,
old_3d: bool = False,
) -> Expr
Serialize each geometry as WKT (Well-Known Text).
Parameters:
-
rounding_precision
(int | None
, default:6
) –The rounding precision when writing the WKT string. Set to None to indicate the full precision.
-
trim
(bool
, default:True
) –If True, trim unnecessary decimals (trailing zeros).
-
output_dimension
(Literal[2, 3, 4]
, default:3
) –The output dimension for the WKT string. Specifying 3 means that up to 3 dimensions will be written but 2D geometries will still be represented as 2D in the WKT string.
-
old_3d
(bool
, default:False
) –Enable old style 3D/4D WKT generation. By default, new style 3D/4D WKT (ie. “POINT Z (10 20 30)”) is returned, but with
old_3d=True
the WKT will be formatted in the style “POINT (10 20 30)”.
polars_st.GeoExprNameSpace.to_ewkt #
to_ewkt(
rounding_precision: int | None = 6,
trim: bool = True,
output_dimension: Literal[2, 3, 4] = 3,
old_3d: bool = False,
) -> Expr
Serialize each geometry as EWKT (Extended Well-Known Text).
Parameters:
-
rounding_precision
(int | None
, default:6
) –The rounding precision when writing the WKT string. Set to None to indicate the full precision.
-
trim
(bool
, default:True
) –If True, trim unnecessary decimals (trailing zeros).
-
output_dimension
(Literal[2, 3, 4]
, default:3
) –The output dimension for the WKT string. Specifying 3 means that up to 3 dimensions will be written but 2D geometries will still be represented as 2D in the WKT string.
-
old_3d
(bool
, default:False
) –Enable old style 3D/4D WKT generation. By default, new style 3D/4D WKT (ie. “POINT Z (10 20 30)”) is returned, but with
old_3d=True
the WKT will be formatted in the style “POINT (10 20 30)”.
polars_st.GeoExprNameSpace.to_wkb #
to_wkb(
output_dimension: Literal[2, 3, 4] = 3,
byte_order: Literal[0, 1] | None = None,
include_srid: bool = False,
) -> Expr
Serialize each geometry as WKB (Well-Known Binary).
Parameters:
-
output_dimension
–The output dimension for the WKB. Specifying 3 means that up to 3 dimensions will be written but 2D geometries will still be represented as 2D in the WKB representation.
-
byte_order
(Literal[0, 1] | None
, default:None
) –Defaults to native machine byte order (
None
). Use 0 to force big endian and 1 for little endian. -
include_srid
(bool
, default:False
) –If True, the SRID is be included in WKB (this is an extension to the OGC WKB specification).
polars_st.GeoExprNameSpace.to_geojson #
to_geojson(indent: int | None = None) -> Expr
Serialize each geometry as GeoJSON.
Parameters:
-
indent
(int | None
, default:None
) –If indent is not
None
, then GeoJSON will be pretty-printed. An indent level of 0 will only insert newlines.None
(the default) outputs the most compact representation.
polars_st.GeoExprNameSpace.to_shapely #
Convert each geometry to a Shapely object.
polars_st.GeoExprNameSpace.has_z #
Return True
for each geometry with z
coordinate values.
polars_st.GeoExprNameSpace.has_m #
Return True
for each geometry with m
coordinate values.
polars_st.GeoExprNameSpace.is_ccw #
Return True
for linear geometries with counter-clockwise coord sequence.
polars_st.GeoExprNameSpace.is_closed #
Return True
for closed linear geometries.
polars_st.GeoExprNameSpace.is_valid_reason #
Return an explanation string for the invalidity of each geometry.
polars_st.GeoExprNameSpace.crosses #
crosses(other: IntoGeoExprColumn) -> Expr
Return True
when each geometry crosses other.
polars_st.GeoExprNameSpace.contains #
contains(other: IntoGeoExprColumn) -> Expr
Return True
when each geometry contains other.
polars_st.GeoExprNameSpace.contains_properly #
contains_properly(other: IntoGeoExprColumn) -> Expr
Return True
when each geometry properly contains other.
polars_st.GeoExprNameSpace.covered_by #
covered_by(other: IntoGeoExprColumn) -> Expr
Return True
when each geometry is covered by other.
polars_st.GeoExprNameSpace.covers #
covers(other: IntoGeoExprColumn) -> Expr
Return True
when each geometry covers other.
polars_st.GeoExprNameSpace.disjoint #
disjoint(other: IntoGeoExprColumn) -> Expr
Return True
when each geometry is disjoint from other.
polars_st.GeoExprNameSpace.dwithin #
dwithin(other: IntoGeoExprColumn, distance: float) -> Expr
Return True
when each geometry is within given distance to other.
polars_st.GeoExprNameSpace.intersects #
intersects(other: IntoGeoExprColumn) -> Expr
Return True
when each geometry intersects other.
polars_st.GeoExprNameSpace.overlaps #
overlaps(other: IntoGeoExprColumn) -> Expr
Return True
when each geometry overlaps other.
polars_st.GeoExprNameSpace.touches #
touches(other: IntoGeoExprColumn) -> Expr
Return True
when each geometry touches other.
polars_st.GeoExprNameSpace.within #
within(other: IntoGeoExprColumn) -> Expr
Return True
when each geometry is within other.
polars_st.GeoExprNameSpace.equals #
equals(other: IntoGeoExprColumn) -> Expr
Return True
when each geometry is equal to other.
polars_st.GeoExprNameSpace.equals_exact #
equals_exact(other: IntoGeoExprColumn, tolerance: float = 0.0) -> Expr
Return True
when each geometry is equal to other.
polars_st.GeoExprNameSpace.equals_identical #
equals_identical(other: IntoGeoExprColumn) -> Expr
Return True
when each geometry is equal to other.
polars_st.GeoExprNameSpace.relate #
relate(other: IntoGeoExprColumn) -> Expr
Return the DE-9IM intersection matrix of each geometry with other.
polars_st.GeoExprNameSpace.relate_pattern #
relate_pattern(other: IntoGeoExprColumn, pattern: str) -> Expr
Return True
when the DE-9IM intersection matrix of geometry with other matches a given pattern.
polars_st.GeoExprNameSpace.union #
union(other: IntoGeoExprColumn, grid_size: float | None = None) -> GeoExpr
Return the union of each geometry with other.
polars_st.GeoExprNameSpace.unary_union #
Return the unary union of each geometry.
polars_st.GeoExprNameSpace.coverage_union #
coverage_union() -> GeoExpr
Return the coverage union of each geometry with other.
polars_st.GeoExprNameSpace.intersection #
intersection(
other: IntoGeoExprColumn, grid_size: float | None = None
) -> GeoExpr
Return the intersection of each geometry with other.
polars_st.GeoExprNameSpace.difference #
difference(other: IntoGeoExprColumn, grid_size: float | None = None) -> GeoExpr
Return the difference of each geometry with other.
polars_st.GeoExprNameSpace.symmetric_difference #
symmetric_difference(
other: IntoGeoExprColumn, grid_size: float | None = None
) -> GeoExpr
Return the symmetric difference of each geometry with other.
polars_st.GeoExprNameSpace.boundary #
boundary() -> GeoExpr
Return the topological boundary of each geometry.
polars_st.GeoExprNameSpace.buffer #
buffer(
distance: IntoDecimalExpr,
quad_segs: int = 8,
cap_style: Literal["round", "square", "flat"] = "round",
join_style: Literal["round", "mitre", "bevel"] = "round",
mitre_limit: float = 5.0,
single_sided: bool = False,
) -> GeoExpr
Return a buffer around each geometry.
polars_st.GeoExprNameSpace.offset_curve #
offset_curve(
distance: IntoDecimalExpr,
quad_segs: int = 8,
join_style: Literal["round", "mitre", "bevel"] = "round",
mitre_limit: float = 5.0,
) -> GeoExpr
Return a line at a given distance of each geometry.
polars_st.GeoExprNameSpace.center #
center() -> GeoExpr
Return the bounding box center of each geometry.
polars_st.GeoExprNameSpace.clip_by_rect #
Clip each geometry by a bounding rectangle.
polars_st.GeoExprNameSpace.convex_hull #
convex_hull() -> GeoExpr
Return the convex hull of each geometry.
polars_st.GeoExprNameSpace.concave_hull #
Return the concave hull of each geometry.
polars_st.GeoExprNameSpace.point_on_surface #
point_on_surface() -> GeoExpr
Return a point that intersects of each geometry.
polars_st.GeoExprNameSpace.remove_repeated_points #
remove_repeated_points(tolerance: IntoDecimalExpr = 0.0) -> GeoExpr
Remove the repeated points for each geometry.
polars_st.GeoExprNameSpace.reverse #
reverse() -> GeoExpr
Reverse the coordinates order of each geometry.
polars_st.GeoExprNameSpace.simplify #
simplify(tolerance: IntoDecimalExpr, preserve_topology: bool = True) -> GeoExpr
Simplify each geometry with a given tolerance.
polars_st.GeoExprNameSpace.flip_coordinates #
flip_coordinates() -> GeoExpr
Flip the x and y coordinates of each geometry.
polars_st.GeoExprNameSpace.snap #
snap(other: IntoGeoExprColumn, tolerance: IntoDecimalExpr) -> GeoExpr
polars_st.GeoExprNameSpace.shortest_line #
shortest_line(other: IntoGeoExprColumn) -> GeoExpr
Return the shortest line between each geometry and other.
polars_st.GeoExprNameSpace.affine_transform #
affine_transform(matrix: IntoExprColumn | Sequence[float]) -> GeoExpr
Apply a 2D or 3D transformation matrix to the coordinates of each geometry.
Parameters:
-
matrix
(IntoExprColumn | Sequence[float]
) –The transformation matrix to apply to coordinates. Should contains 6 elements for a 2D transform or 12 for a 3D transform. The matrix elements order should be: -
m11
,m12
,m21
,m22
,tx
,ty
for 2D transformations -m11
,m12
,m13
,m21
,m22
,m23
,m31
,m32
,m33
,tx
,ty
,tz
for 3D transformations
polars_st.GeoExprNameSpace.translate #
translate(
x: IntoDecimalExpr = 0.0, y: IntoDecimalExpr = 0.0, z: IntoDecimalExpr = 0.0
) -> GeoExpr
polars_st.GeoExprNameSpace.rotate #
rotate(
angle: IntoDecimalExpr,
origin: (
Literal["center", "centroid"] | Sequence[float] | Expr | Series
) = "center",
) -> GeoExpr
polars_st.GeoExprNameSpace.scale #
scale(
x: IntoDecimalExpr = 1.0,
y: IntoDecimalExpr = 1.0,
z: IntoDecimalExpr = 1.0,
origin: (
Literal["center", "centroid"] | Sequence[float] | Expr | Series
) = "center",
) -> GeoExpr
polars_st.GeoExprNameSpace.interpolate #
interpolate(distance: IntoDecimalExpr, normalized: bool = False) -> GeoExpr
polars_st.GeoExprNameSpace.total_bounds #
Return the total bounds of all geometries.
polars_st.GeoExprNameSpace.multipoint #
multipoint() -> GeoExpr
Aggregate Point geometries into a single MultiPoint.
polars_st.GeoExprNameSpace.multilinestring #
multilinestring() -> GeoExpr
Aggregate LineString geometries into a single MultiLineString.
polars_st.GeoExprNameSpace.multipolygon #
multipolygon() -> GeoExpr
Aggregate Polygon geometries into a single MultiPolygon.
polars_st.GeoExprNameSpace.geometrycollection #
geometrycollection() -> GeoExpr
Aggregate geometries into a single GeometryCollection.
polars_st.GeoExprNameSpace.collect #
collect() -> GeoExpr
Aggregate geometries into a single MultiPart geometry or GeometryCollection.
polars_st.GeoExprNameSpace.union_all #
Return the union of all geometries.
polars_st.GeoExprNameSpace.coverage_union_all #
coverage_union_all() -> GeoExpr
Return the coverage union of all geometries.
polars_st.GeoExprNameSpace.intersection_all #
Return the intersection of all geometries.
polars_st.GeoExprNameSpace.difference_all #
Return the difference of all geometries.
polars_st.GeoExprNameSpace.symmetric_difference_all #
Return the symmetric difference of all geometries.