ST_Collect¶
Introduction:
Build an appropriate Geometry, MultiGeometry, or GeometryCollection to contain the Geometrys in it. For example:
- If
geomListcontains a singlePolygon, thePolygonis returned. - If
geomListcontains severalPolygons, aMultiPolygonis returned. - If
geomListcontains somePolygons and someLineStrings, aGeometryCollectionis returned. - If
geomListis empty, an emptyGeometryCollectionis returned.
Note that this method does not "flatten" Geometries in the input, and hence if any MultiGeometries are contained in the input, a GeometryCollection containing them will be returned.
Format
ST_Collect(*geom: geometry)
Example:
WITH src_tbl AS (
SELECT sedona.ST_GeomFromText('POINT (40 10)') AS geom
UNION
SELECT sedona.ST_GeomFromText('LINESTRING (0 5, 0 10)') AS geom
)
SELECT sedona.ST_AsText(collection)
FROM src_tbl,
TABLE(sedona.ST_Collect(src_tbl.geom) OVER (PARTITION BY 1));
Result:
GEOMETRYCOLLECTION (POINT (40 10), LINESTRING (0 5, 0 10))