snowflake.snowpark.functions.st_makepolygonoriented¶

snowflake.snowpark.functions.st_makepolygonoriented(geography_expression: Union[snowflake.snowpark.column.Column, str]) → Column[source]¶

Returns a polygon with vertices oriented in a consistent direction (counter-clockwise for exterior rings, clockwise for interior rings).

Parameters:

geography_expression (ColumnOrName) – The geography expression (typically a LINESTRING) to convert to an oriented polygon.

Returns:

The oriented polygon geometry.

Return type:

Column

Examples::
>>> from snowflake.snowpark.functions import col, to_geography
>>> import json
>>> df = session.create_dataframe([
...     "LINESTRING(0.0 0.0, 1.0 0.0, 1.0 2.0, 0.0 2.0, 0.0 0.0)"
... ], schema=["linestring"])
>>> result = df.select(st_makepolygonoriented(to_geography(col("linestring"))).alias("polygon")).collect()
>>> assert json.loads(result[0]["POLYGON"]) == {
... "coordinates": [
...     [
...         [0, 0],
...         [1, 0],
...         [1, 2],
...         [0, 2],
...         [0, 0]
...     ]
... ],
... "type": "Polygon"
... }
Copy