ST_GeomCollFromText — Return a specified Geometry Collection object.
geometry ST_GeomCollFromText(varchar WKT, integer
SRID);
geometry ST_GeomCollFromText(varchar WKT);
Construct a GeometryCollection from a well-known text representation of a Geometry Collection value. If WKT is not a valid geometrycollection, returns null.
The spatial reference system identifier is set to -1 if not given.
| 2D | 3D | M |
|---|---|---|
![]() | ![]() | ![]() |
| OGC SFS for SQL. 1.1 (1999) | OGC SFS for SQL. 1.1.0 (2005) | OGC SFS for SQL. 1.2.0 (2006) | SQL-MM Part 3 |
|---|---|---|---|
| 3.2.6.2 | 7.2.6.1 | - | 9.1.6 |
--EWKT of a GeometryCollection, with SRID
SELECT ST_asewkt(ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT (5 5 10 -2),LINESTRING (0 0 10 -4, 0 50 10 -4))',25830)) as GC;
--Result
GC
SRID=25830;GEOMETRYCOLLECTION (POINT (5 5 10 -2), LINESTRING (0 0 10 -4, 0 50 10 -4))
--Return the SRID from a GeometryCollection
SELECT ST_SRID(ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT (5 5))'));
st_srid
---------
-1
(1 row)