snowflake.snowpark.functions.st_centroid¶
- snowflake.snowpark.functions.st_centroid(geography_or_geometry_expression: Union[snowflake.snowpark.column.Column, str]) Column [source]¶
Returns the centroid of a GEOGRAPHY or GEOMETRY object as a POINT object.
- Parameters:
geography_or_geometry_expression (ColumnOrName) – A GEOGRAPHY or GEOMETRY object
- Returns:
A POINT object representing the centroid of the input geometry
- Return type:
- Examples::
>>> from snowflake.snowpark.functions import to_geography >>> df = session.create_dataframe([ ... ["POLYGON((10 10, 10 20, 20 20, 20 10, 10 10))"], ... ["LINESTRING(0 0, 0 -2)"] ... ], schema=["geom"]) >>> result = df.select(st_centroid(to_geography(df["geom"])).alias("centroid")).collect() >>> result [Row(CENTROID='{\n "coordinates": [\n 1.500000000000002e+01,\n 1.501481985543850e+01\n ],\n "type": "Point"\n}'), Row(CENTROID='{\n "coordinates": [\n 0.000000000000000e+00,\n -9.999999999999998e-01\n ],\n "type": "Point"\n}')]