ST_MultiPolygon function

The ST_MultiPolygon constructs a multipolygon from a given input.

The input can be given in one of the following format:
  • A well-known text representation
  • A well-known binary representation
  • A shape representation
  • A representation in the geography markup language (GML)
An optional spatial reference system identifier can be specified to identify the spatial reference system that the resulting multipolygon is in.

If the well-known text representation, the well-known binary representation, the shape representation, or the GML representation is null, then null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_MultiPolygon?wktwkbshapegml,srs_id)

Parameters

wkt
A value of type CLOB(2G) that contains the well-known text representation of the resulting multipolygon.
wkb
A value of type BLOB(2G) that contains the well-known binary representation of the resulting multipolygon.
gml
A value of type CLOB(2G) that represents the resulting multipolygon using the geography markup language.
shape
A value of type BLOB(2G) that represents the shape 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 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.

This example illustrates how ST_MultiPolygon can be used to create and insert a multipolygon from its well-known text representation. The record that is inserted has ID = 1110, and the geometry is a multipolygon in spatial reference system 1. The multipolygon is in the well-known text representation of a multipolygon. The X and Y coordinates for this geometry are:
  • 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_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.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)))