This topic describes the ST_MPolyFromText function. This function constructs a MultiPolygon object by using a Well-Known Text (WKT) string and a spatial reference identifier (SRID).
Syntax
geometry ST_MPolyFromText(text wKT , integer srid);
geometry ST_MPolyFromText(text wKT);
Parameters
Parameter | Description |
---|---|
wKT | The WKT string that you want to specify. |
srid | The SRID of the MultiPolygon object. |
Description
- If you can make sure that the information that you specify can be used to construct a MultiPolygon object, we recommend that you use the ST_GeomFromText function, which constructs a geometry object at a higher speed because no unnecessary checks are required.
- If you do not specify an SRID, the default SRID 0 is used.
- If the WKT string that you specify does not represent a MultiPolygon object, this function returns NULL.
Examples
SELECT ST_AsText(ST_MPolyFromText('MULTIPOLYGON(((0 0,1 0,1 1,0 0),(1 1,2 1,2 2,1 1)))'));
st_astext
-----------------------------------------------------
MULTIPOLYGON(((0 0,1 0,1 1,0 0),(1 1,2 1,2 2,1 1)))
(1 row)