Documentation Index
Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
Use this file to discover all available pages before exploring further.
Returns a homogeneous multi-geometry from a given geometry collection.
The type numbers are:
- POINT
- LINESTRING
- POLYGON
If the type parameter is omitted a multi-geometry of the highest dimension is returned.
Signatures
ST_CollectionExtract (A: Geometry)
ST_CollectionExtract (A: Geometry, type: Integer)
Parameters
Return type
Example
WITH test_data as (
ST_GeomFromText(
'GEOMETRYCOLLECTION(POINT(40 10), POLYGON((0 0, 0 5, 5 5, 5 0, 0 0)))'
) as geom
)
SELECT ST_CollectionExtract(geom) as c1, ST_CollectionExtract(geom, 1) as c2
FROM test_data
+----------------------------------------------------------------------------+
|c1 |c2 |
+----------------------------------------------------------------------------+
|MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0))) |MULTIPOINT(40 10) | |
+----------------------------------------------------------------------------+