ST_Polygon
The ST_Polygon function has two variations.
In the first variation, ST_Polygon constructs a polygon 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 polygon is in.
In the second variation, ST_Polygon takes ST_Geometry as an input parameter and casts the output type to ST_Polygon. If the given geometry is null, then null is returned.
Syntax
Variation 1
Parameters
- wkt
- A value of type CLOB(8M) that contains the well-known text representation of the resulting polygon. 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 polygon. 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 polygon. 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 polygon.
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
db2gse.ST_Polygon
Syntax
Variation 2
Parameter
- geometry
- A value of type ST_Geometry.
Return type
ST_Polygon
Example
In the following example, the lines of results have been reformatted for readability.
SET CURRENT PATH = CURRENT PATH, db2gse;
CREATE TABLE sample_polys (id INTEGER, geometry ST_Polygon);
INSERT INTO sample_polys
VALUES (1101,
ST_Polygon ('polygon
((110 120, 110 140, 120 130, 110 120))', 1));
The following SELECT statement returns the polygon that
was recorded in the table:
SELECT id, CAST( ST_AsText( geometry ) AS VARCHAR(120) ) POLYGONS
FROM sample_polys;
Results:
ID POLYGONS
------- ----------------------------------------------------------------
1101 POLYGON (( 110.000000 120.000000, 120.000000 130.000000,
110.000000 140.000000, 110.000000 120.000000))
