snowflake.snowpark.functions.st_distance

snowflake.snowpark.functions.st_distance(geography_or_geometry_expression_1: Union[snowflake.snowpark.column.Column, str], geography_or_geometry_expression_2: Union[snowflake.snowpark.column.Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.41.0/src/snowflake/snowpark/_functions/scalar_functions.py#L2855-L2884)

Returns the minimum geodesic distance between two GEOGRAPHY objects or the Euclidean distance between two GEOMETRY objects.

Parameters:
  • geography_or_geometry_expression_1 (ColumnOrName) – A GEOGRAPHY or GEOMETRY objects.

  • geography_or_geometry_expression_2 (ColumnOrName) – A GEOGRAPHY or GEOMETRY objects.

Returns:

The distance between the two geographic or geometric objects.

Return type:

Column

Examples

>>> df = session.sql("select TO_GEOGRAPHY('POINT(0 0)') as point1, TO_GEOGRAPHY('POINT(1 0)') as point2")
>>> df.select(st_distance(df.point1, df.point2).alias("distance")).collect()
[Row(DISTANCE=111195.10117748393)]
Copy
Language: English