You are viewing documentation about an older version (1.8.0). View latest version

snowflake.snowpark.functions.st_length¶

snowflake.snowpark.functions.st_length(geography_or_geometry_expression: Union[snowflake.snowpark.column.Column, str]) → Column[source]¶
Returns the length of a GEOGRAPHY or GEOMETRY object. The value is a REAL value, which represents the length:
  • For GEOGRAPHY input values, the length is in meters.

  • For GEOMETRY input values, the length is computed with the same units used to define the input coordinates.

Parameters:

geography_or_geometry_expression (ColumnOrName) – A GEOGRAPHY or GEOMETRY objects

Returns:

Returns a REAL value, which represents the length:
  • For GEOGRAPHY input values, the length is in meters.

  • For GEOMETRY input values, the length is computed with the same units used to define the input coordinates.

Return type:

Column

Examples::
>>> from snowflake.snowpark.functions import to_geography
>>> df = session.create_dataframe([
...     "LINESTRING(0 0, 1 1)",
...     "POINT(1 1)",
...     "POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))"
... ], schema=["geometry_col"])
>>> df.select(st_length(to_geography(df["geometry_col"])).alias("length")).collect()
[Row(LENGTH=157249.6280925079), Row(LENGTH=0.0), Row(LENGTH=0.0)]
Copy