snowflake.snowpark.functions.st_intersection

snowflake.snowpark.functions.st_intersection(geography_expression_1: Union[snowflake.snowpark.column.Column, str], geography_expression_2: Union[snowflake.snowpark.column.Column, str]) Column[source]

Returns the intersection of two GEOGRAPHY objects. If the objects do not intersect, returns an empty geometry collection.

Parameters:
  • geography_expression_1 (ColumnOrName) – A column containing GEOGRAPHY objects or a geography expression.

  • geography_expression_2 (ColumnOrName) – A column containing GEOGRAPHY objects or a geography expression.

Returns:

A column containing the intersection of the two input GEOGRAPHY objects as a GEOGRAPHY object.

Return type:

Column

Examples::
>>> from snowflake.snowpark.functions import to_geography
>>> 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_intersection(to_geography(df["geog1"]), to_geography(df["geog2"])).alias("intersection")).collect()
[Row(INTERSECTION='{\n  "coordinates": [\n    [\n      [\n        [\n          1.500000000000000e+00,\n          5.000571197534015e-01\n        ],\n        [\n          2.000000000000000e+00,\n          1.000000000000000e+00\n        ],\n        [\n          1.500000000000000e+00,\n          1.500171359265506e+00\n        ],\n        [\n          9.999999999999998e-01,\n          1.000000000000000e+00\n        ],\n        [\n          1.500000000000000e+00,\n          5.000571197534015e-01\n        ]\n      ]\n    ],\n    [\n      [\n        [\n          1.500000000000000e+00,\n          2.500285598878384e+00\n        ],\n        [\n          2.000000000000000e+00,\n          3.000000000000000e+00\n        ],\n        [\n          1.500000000000000e+00,\n          3.500399838942360e+00\n        ],\n        [\n          1.000000000000000e+00,\n          3.000000000000000e+00\n        ],\n        [\n          1.500000000000000e+00,\n          2.500285598878384e+00\n        ]\n      ]\n    ]\n  ],\n  "type": "MultiPolygon"\n}')]
Copy