snowflake.snowpark.functions.st_dwithin¶

snowflake.snowpark.functions.st_dwithin(geography_expression_1: Union[snowflake.snowpark.column.Column, str], geography_expression_2: Union[snowflake.snowpark.column.Column, str], distance_in_meters: Union[snowflake.snowpark.column.Column, str]) → Column[source]¶

Returns true if the distance between two GEOGRAPHY objects is within the specified distance in meters.

Parameters:
  • geography_expression_1 (ColumnOrName) – The first geography expression to compare

  • geography_expression_2 (ColumnOrName) – The second geography expression to compare

  • distance_in_meters (ColumnOrName) – The maximum distance in meters for the comparison

Returns:

A boolean column indicating whether the two geography objects are within the specified distance

Return type:

Column

Examples

>>> from snowflake.snowpark.functions import st_makepoint, lit
>>> df = session.create_dataframe([
...     [0.0, 0.0, 1.0, 0.0, 150000.0],
...     [0.0, 0.0, 2.0, 0.0, 150000.0]
... ], schema=["x1", "y1", "x2", "y2", "distance"])
>>> df.select(
...     st_dwithin(
...         st_makepoint(df["x1"], df["y1"]),
...         st_makepoint(df["x2"], df["y2"]),
...         df["distance"]
...     ).alias("within_distance")
... ).collect()
[Row(WITHIN_DISTANCE=True), Row(WITHIN_DISTANCE=False)]
Copy