snowflake.snowpark.functions.st_within

snowflake.snowpark.functions.st_within(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.42.0/src/snowflake/snowpark/_functions/scalar_functions.py#L3437-L3464)

Returns TRUE if the first GEOGRAPHY object is completely inside the second GEOGRAPHY object.

Parameters:
  • geography_or_geometry_expression_1 (ColumnOrName) – A GEOGRAPHY or GEOMETRY object to test if it’s within the second object.

  • geography_or_geometry_expression_2 (ColumnOrName) – A GEOGRAPHY or GEOMETRY object that may contain the first object.

Returns:

Boolean value indicating whether the first geography is within the second geography.

Return type:

Column

Examples::
>>> df = session.create_dataframe([
...     ('POLYGON((1 1, 2 1, 2 2, 1 2, 1 1))', 'POLYGON((0 0, 3 0, 3 3, 0 3, 0 0))'),
...     ('POINT(1.5 1.5)', 'POLYGON((1 1, 2 1, 2 2, 1 2, 1 1))')
... ], schema=["g1", "g2"])
>>> from snowflake.snowpark.functions import to_geography
>>> df.select(st_within(to_geography(df["g1"]), to_geography(df["g2"])).alias("within")).collect()
[Row(WITHIN=True), Row(WITHIN=True)]
Copy
Language: English