ST_UNION()
All functions > GEOSPATIAL > ST_UNION()
Returns the geometry/geography representing the point set union of two inputs.
Signatures
Union
Returns: Union; sub kind depends on merged shape
ST_UNION(geo1: T, geo2: T) → GEOMETRY or GEOGRAPHY sql
| Parameter | Type | Required | Description |
|---|---|---|---|
geo1 | T | Yes | First geometry or geography |
geo2 | T | Yes | Second geometry or geography |
With:
T: Custom types: GEOM_POINT | GEOM_LINESTRING | GEOM_POLYGON | GEOM_MULTIPOINT | GEOM_MULTILINESTRING | GEOM_MULTIPOLYGON | GEOM_MULTIANY | GEOG_POINT | GEOG_LINESTRING | GEOG_POLYGON | GEOG_MULTIPOINT | GEOG_MULTILINESTRING | GEOG_MULTIPOLYGON | GEOG_MULTIANY
Signature notes:
- Merges two geometries into one, dissolving shared boundaries
- On Trino: transpiled to geometry_union()
- Both inputs must be the same type family
- Returns NULL if either input is NULL
Examples
FeatureQL
SELECT
f1 := ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))'), ST_GEOMFROMTEXT('POLYGON ((1 0, 3 0, 3 2, 1 2, 1 0))'))) -- Union of two adjacent rectangles (WKT vertex order may vary)
;Result
| f1 VARCHAR |
|---|
| POLYGON ((0 0, 0 2, 1 2, 2 2, 3 2, 3 0, 2 0, 1 0, 0 0)) |
On this page