Skip to content

ST_Union_Agg

Returns a geometry that represents the point set union of all geometries.

Usage

geometry ST_Union_Agg(geom: geometry)

Arguments

  • geom (geometry): Input geometry

Examples

SELECT ST_Union_Agg(geom) FROM (
  VALUES
    (ST_GeomFromText('POLYGON ((0 0, 0 2, 2 2, 2 0, 0 0))')),
    (ST_GeomFromText('POLYGON ((1 1, 1 3, 3 3, 3 1, 1 1))'))
) AS t(geom);
┌───────────────────────────────────────────────────────┐
│                  st_union_agg(t.geom)                 │
│                        geometry                       │
╞═══════════════════════════════════════════════════════╡
│ MULTIPOLYGON(((0 2,0 0,2 0,2 1,3 1,3 3,1 3,1 2,0 2))) │
└───────────────────────────────────────────────────────┘