snowflake.snowpark.functions.st_difference¶
- snowflake.snowpark.functions.st_difference(geography_expression_1: Union[snowflake.snowpark.column.Column, str], geography_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#L2450-L2477)¶
Returns the difference between two GEOGRAPHY objects. The result is a GEOGRAPHY object that represents the portion of the first geography that does not intersect with the second geography.
- Parameters:
geography_expression_1 (ColumnOrName) – GEOGRAPHY objects or a geography expression representing the first geography
geography_expression_2 (ColumnOrName) – GEOGRAPHY objects or a geography expression representing the second geography
- Returns:
GEOGRAPHY objects representing the difference between the two input geographies
- Return type:
- Examples::
>>> from snowflake.snowpark.functions import to_geography, col >>> df = session.create_dataframe([ ... ["POLYGON((0 0, 1 0, 2 1, 1 2, 2 3, 1 4, 0 4, 0 0))", "POLYGON((3 0, 3 4, 2 4, 1 3, 2 2, 1 1, 2 0, 3 0))"] ... ], schema=["geog1", "geog2"]) >>> df.select(st_difference(to_geography(col("geog1")), to_geography(col("geog2"))).alias("difference")).collect() [Row(DIFFERENCE='{\n "coordinates": [\n [\n [\n 9.999999999999998e-01,\n 1.000000000000000e+00\n ],\n [\n 1.500000000000000e+00,\n 1.500171359265506e+00\n ],\n [\n 9.999999999999998e-01,\n 2.000000000000000e+00\n ],\n [\n 1.500000000000000e+00,\n 2.500285598878384e+00\n ],\n [\n 1.000000000000000e+00,\n 3.000000000000000e+00\n ],\n [\n 1.500000000000000e+00,\n 3.500399838942360e+00\n ],\n [\n 1.000000000000000e+00,\n 4.000000000000000e+00\n ],\n [\n 0.000000000000000e+00,\n 4.000000000000000e+00\n ],\n [\n 0.000000000000000e+00,\n 0.000000000000000e+00\n ],\n [\n 1.000000000000000e+00,\n 0.000000000000000e+00\n ],\n [\n 1.500000000000000e+00,\n 5.000571197534015e-01\n ],\n [\n 9.999999999999998e-01,\n 1.000000000000000e+00\n ]\n ]\n ],\n "type": "Polygon"\n}')]