Fork me on GitHub

ST_MPolyFromText

Signature

GEOMETRY ST_MPolyFromText(VARCHAR wkt);
GEOMETRY ST_MPolyFromText(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 MULTIPOLYGON.

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_MPolyFromText(
    'MULTIPOLYGON (((10 40, 5 20, 20 30, 10 40)), 
                   ((30 40, 15 11, 30 10, 35 25, 30 40)))');
-- Answer: MULTIPOLYGON (((10 40, 5 20, 20 30, 10 40)),
--                       ((30 40, 15 11, 30 10, 35 25, 30 40)))

SELECT ST_MPolyFromText(
    'MULTIPOLYGON(((28 26, 28 0, 84 0, 84 42, 28 26),
                   (52 18, 66 23, 73 9, 48 6, 52 18)),
                  ((59 18, 67 18, 67 13, 59 13, 59 18)))', 101);
-- Answer: MULTIPOLYGON(((28 26, 28 0, 84 0, 84 42, 28 26),
--                       (52 18, 66 23, 73 9, 48 6, 52 18)),
--                      ((59 18, 67 18, 67 13, 59 13, 59 18)))

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