ST_Union takes two or more geometry columns and returns a geometry column. The output column contains the geometries that represent the spatial union of the geometries in each row of the input columns. The geometry types of the input columns must be the same. To find the union of all geometries in a group or column use ST_Aggr_Union.
Function | Syntax |
---|---|
Python | union(*geometries) |
SQL | ST |
Scala | union(geometries) |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for union.
This function implements the OpenGIS Simple Features Implementation Specification for SQL 1.2.1.
Python and SQL Examples
from geoanalytics_fabric.sql import functions as ST, Point, Polygon
df = spark.createDataFrame([(Point(8,8), Polygon([[[0,0],[10,0],[10,10],[0,10]]]),)], ["point", "polygon"])
df.select(ST.union(ST.buffer("point", 5), "polygon")).st.plot()
Scala Example
import com.esri.geoanalytics.geometry._
import com.esri.geoanalytics.sql.{functions => ST}
import org.apache.spark.sql.{functions => F}
case class GeometryRow(point: Point, polygon: Polygon)
val data = Seq(GeometryRow(Point(8, 8), Polygon(Point(0, 0), Point(0, 10), Point(10, 10), Point(10, 0))))
val df = spark.createDataFrame(data)
.select(ST.union(ST.buffer($"point", 5), $"polygon").alias("union"))
.withColumn("union_area", F.round(ST.area($"union"),3))
df.show()
+--------------------+----------+
| union|union_area|
+--------------------+----------+
|{"rings":[[[0,0],...| 135.417|
+--------------------+----------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |