Fork me on GitHub

ST_PolyFromText

Signature

GEOMETRY ST_PolyFromText(VARCHAR wkt);
GEOMETRY ST_PolyFromText(VARCHAR wkt, INT srid);

Description

Converts the Well Known Text wkt into a Geometry, optionally with spatial reference id srid. Verifies that wkt does in fact specify a POLYGON.

Note: If wkt specifies a Geometry with z-coordinates, they will be conserved in reality but suppressed when visualizing the Geometry as WKT.

Implements the OpenGIS Simple Features Implementation Specification for SQL version 1.2.1.

Examples

SELECT ST_PolyFromText('POLYGON ((49 30, 50 28, 53 28, 53 32, 50 32, 49 30))');
-- Answer: POLYGON ((49 30, 50 28, 53 28, 53 32, 50 32, 49 30))

SELECT ST_PolyFromText('POLYGON((50 31, 54 31, 54 29, 50 29, 50 31))', 2154);
-- Answer: POLYGON((50 31, 54 31, 54 29, 50 29, 50 31))

SELECT ST_PolyFromText('POINT(2 3)', 2154);
-- Answer: The provided WKT Geometry is not a POLYGON.
See also