Name

ST_GeomFromText — Return a geometric object given its Well-known text Representation.

Synopsis

geometry ST_GeomFromText(varchar WKT, integer SRID);

geometry ST_GeomFromText(varchar WKT);

Alias

GeomFromText, ST_GeometryFromText, GeometryFromText

Description

The GeomFromText function takes a geometry textual representation and a Spatial Reference System ID (SRID) and creates an instance of the appropriate Geometry Type. If the SRID is not provides it defaults to -1.

The return type of the GeomFromText function is the Geometry supertype. For construction of a geometric object to be stored in columns restricted to a particular subtype, use the type-specific construction function.

[Note]

ST_AsText is the reverse of ST_GeomFromText.

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

Examples

SELECT ST_GeometryFromText('POLYGON ((20 20, 50 20, 50 50, 20 50, 20 20))',25830);

SELECT ST_GeometryFromText('POLYGON ((20 20, 50 20, 50 50, 20 50, 20 20))');

SELECT ST_GeometryFromText('MULTIPOINT (0 0 0 0, 1 1 1 1)');

SELECT ST_GeometryFromText('POINTM (0 0 -4)');

Related functions

ST_AsText, ST_GeomFromEWKT