Name

ST_GeomCollFromText — Return a specified Geometry Collection object.

Synopsis

geometry ST_GeomCollFromText(varchar WKT, integer SRID);

geometry ST_GeomCollFromText(varchar WKT);

Alias

GeomCollFromText

Description

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.

Coordinate Dimensions
2D3DM
Spatial Standards Support
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.27.2.6.1-9.1.6

Examples

--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)

Related functions

ST_GeomFromText