Skip to content

ST_UnaryUnion

Returns a single geometry which is the union of all components.

Usage

geometry ST_UnaryUnion(geom: geometry)

Arguments

  • geom (geometry): Input geometry

Description

Returns a single geometry which is the union of all components of the input geometry. Useful for computing the union of a set of geometries stored in a single geometry (e.g., a GEOMETRYCOLLECTION or MULTI* geometry).

Examples

SELECT ST_UnaryUnion(ST_GeomFromWKT('MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0)), ((10 0, 20 0, 20 10, 10 10, 10 0)))'));
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_unaryunion(st_geomfromwkt(Utf8("MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0  │
│                 0)), ((10 0, 20 0, 20 10, 10 10, 10 0)))")))…                │
╞══════════════════════════════════════════════════════════════════════════════╡
│ POLYGON((0 0,0 10,10 10,20 10,20 0,10 0,0 0))                                │
└──────────────────────────────────────────────────────────────────────────────┘