This topic describes the ST_GeomCollFromText function. This function constructs a GeometryCollection object by using a Well-Known Text (WKT) string and a spatial reference identifier (SRID).

Syntax

geometry  ST_GeomCollFromText(text  WKT , integer  srid);
geometry  ST_GeomCollFromText(text  WKT);

Parameters

Parameter Description
WKT The WKT string that you want to specify.
srid The SRID of the GeometryCollection object.

Description

  • If you do not specify an SRID, the default SRID 0 is used.
  • If the WKT string that you specify does not represent a GeometryCollection object, this function returns an error.
  • If you cannot make sure that the WKT string that you specify represents a GeometryCollection object, do not use this function. This function requires additional verification steps. As a result, this function constructs geometry objects at lower speeds than the ST_GeomFromText function.

Examples

SELECT ST_AsText(ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4, 5 6))'));
                     st_astext
----------------------------------------------------
 GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))
(1 row)