Constructs a GeometryCollection geometry from a Well-Known Text (WKT) string and an optional spatial reference identifier (SRID).
Syntax
geometry ST_GeomCollFromText(text WKT, integer srid);
geometry ST_GeomCollFromText(text WKT);Parameters
| Parameter | Type | Description |
|---|---|---|
WKT | text | A WKT string representing a GeometryCollection. |
srid | integer | The SRID to assign to the geometry. Defaults to 0 if not specified. |
Usage notes
If the WKT string does not represent a GeometryCollection, the function returns an error.
This function performs additional type verification before constructing the geometry, which makes it slower than
ST_GeomFromText. UseST_GeomFromTextwhen the input type does not need to be validated as a GeometryCollection.
Example
SELECT ST_AsText(ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4, 5 6))'));Output:
st_astext
----------------------------------------------------
GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))
(1 row)