All Products
Search
Document Center

PolarDB:ST_GeomCollFromText

Last Updated:Mar 28, 2026

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

ParameterTypeDescription
WKTtextA WKT string representing a GeometryCollection.
sridintegerThe 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. Use ST_GeomFromText when 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)