ST_MPolyFromText function
The ST_MPolyFromText function takes a well-known text representation of a multipolygon and, optionally, a spatial reference system identifier as input parameters and returns the corresponding multipolygon.
If the given well-known text representation is null, then null is returned.
The recommended function for achieving the same result is the ST_MultiPolygon function. It is recommended because of its flexibility: ST_MultiPolygon takes additional forms of input as well as the well-known text representation.
Syntax
Parameters
- wkt
- A value of type CLOB(2G) that contains the well-known text representation of the resulting multipolygon.
- srs_id
- A value of type INTEGER that identifies the spatial reference
system for the resulting multipolygon.
If the srs_id parameter is omitted, the spatial reference system with the numeric identifier 0 (zero) is used.
If the specified srs_id does not identify a spatial reference system listed in the catalog view DB2GSE.ST_SPATIAL_REFERENCE_SYSTEMS, then an exception condition is raised (SQLSTATE 38SU1).
Return type
db2gse.ST_MultiPolygon
Example
In the following example, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display.
- Polygon 1: (3, 3) (4, 6) (5, 3) (3, 3)
- Polygon 2: (8, 24) (9, 25) (1, 28) (8, 24)
- Polygon 3: (13, 33) (7, 36) (1, 40) (10, 43) (13, 33)
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_mpolys (id INTEGER, geometry ST_MultiPolygon)
INSERT INTO sample_mpolys
VALUES (1110,
ST_MPolyFromText ('multipolygon (( (3 3, 4 6, 5 3, 3 3),
(8 24, 9 25, 1 28, 8 24),
(13 33, 7 36, 1 40, 10 43 13 33) ))', 1) )
The following SELECT statement returns the multipolygon
that was recorded in the table:
SELECT id, CAST( ST_AsText( geometry ) AS VARCHAR(350) ) MULTI_POLYGON
FROM sample_mpolys
WHERE id = 1110
Results:
ID MULTI_POLYGON
------- --------------------------------------------------------------------
1110 MULTIPOLYGON ((( 13.00000000 33.00000000, 10.00000000 43.00000000,
1.00000000 40.00000000, 7.00000000 36.00000000,
13.00000000 33.00000000)),
(( 8.00000000 24.00000000, 9.00000000 25.00000000,
1.00000000 28.0000000, 8.00000000 24.00000000)),
( 3.00000000 3.00000000, 5.00000000 3.00000000,
4.00000000 6.00000000, 3.00000000 3.00000000)))