snowflake.snowpark.functions.st_union¶

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

Returns the union of two GEOGRAPHY objects as a single GEOGRAPHY object.

Parameters:
  • geography_expression_1 (ColumnOrName) – A GEOGRAPHY object.

  • geography_expression_2 (ColumnOrName) – A GEOGRAPHY object.

Returns:

The union of the two input GEOGRAPHY objects.

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"])
>>> result = df.select(st_union(to_geography(df["geog1"]), to_geography(df["geog2"])).alias("union_result")).collect()
>>> # [Row(UNION_RESULT='{\n  "coordinates": [\n    [\n      [\n        3.000000000000000e+00,\n        0.000000000000000e+00\n      ],\n      [\n        3.000000000000000e+00,\n        4.000000000000000e+00\n      ],\n      [\n        2.000000000000000e+00,\n        4.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        2.000000000000000e+00,\n        0.000000000000000e+00\n      ],\n      [\n        3.000000000000000e+00,\n        0.000000000000000e+00\n      ]\n    ],\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        2.000000000000000e+00,\n        2.000000000000000e+00\n      ],\n      [\n        1.500000000000000e+00,\n        1.500171359265506e+00\n      ]\n    ]\n  ],\n  "type": "Polygon"\n}')]
Copy