ST_MultiPolygon
The ST_MultiPolygon function has two variations.
In the first variation, ST_MultiPolygon constructs a multipolygon from a well-known text representation, a well-known binary representation, an ESRI shape representation, or a Geography Markup Language (GML) representation. An optional spatial reference system identifier can be specified to identify the spatial reference system that the resulting multipolygon is in.
In the second variation, ST_MultiPolygon takes ST_Geometry as an input parameter and casts the output type to ST_MultiPolygon. If the given geometry is null, then null is returned.
Syntax for variation 1
Variation 1
Parameters for variation 1
- wkt
- A value of type CLOB(8M) that contains the well-known text representation of the resulting multipolygon. If the well-known text representation is null, then null is returned.
- wkb
- A value of type BLOB(4M) that contains the well-known binary representation of the resulting multipolygon. If the well-known binary representation is null, then null is returned.
- shape
- A value of type BLOB(4M) that contains the shape representation of the resulting multipolygon. If the shape representation is null, then null is returned.
- gml
- A value of type CLOB(8M) that contains the GML representation of the geometry. If the GML representation is null, then null is returned.
- srs_id
- A value of type INTEGER that identifies the spatial reference
system for the resulting multipolygon.
If srs_id does not identify a spatial reference system listed in the catalog view DB2GSE.ST_SPATIAL_REFERENCE_SYSTEMS, an error is returned (SQLSTATE 38SU1).
Return type for variation 1
db2gse.ST_MultiPolygon
Syntax for variation 2
Variation 2
Parameter for variation 2
- geometry
- A value of type ST_Geometry.
Return type for variation 2
ST_MultiPolygon
Examples
In the following example, the lines of results have been reformatted for readability.
- 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 PATH = CURRENT PATH, db2gse;
CREATE TABLE sample_mpolys (id INTEGER, geometry ST_MultiPolygon);
INSERT INTO sample_mpolys
VALUES (1110,
ST_MultiPolygon ('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.000000 33.000000, 10.000000 43.000000,
1.000000 40.000000, 7.000000 36.000000,
13.000000 33.000000)),
(( 8.000000 24.000000, 9.000000 25.000000,
1.000000 28.00000, 8.000000 24.000000)),
(( 3.000000 3.000000, 5.000000 3.000000,
4.000000 6.000000, 3.000000 3.000000)))
