User's Guide and Reference

ST_ConvexHull

ST_ConvexHull takes a geometry object and returns the convex hull.

Syntax

db2gse.ST_ConvexHull(g db2gse.ST_Geometry)

Return type

db2gse.ST_Geometry

Examples

The example creates the CONVEXHULL_TEST table that has two columns: GEOTYPE and G1. The GEOTYPE column, a varchar(20), will store the name of the subclass of geometry that is stored in G1, which is defined as a geometry.

CREATE TABLE CONVEXHULL_TEST (geotype varchar(20), g1 db2gse.ST_Geometry)

Each INSERT statement inserts a geometry of each subclass type into the CONVEXHULL_TEST table.

INSERT INTO CONVEXHULL_TEST
VALUES('Point',
       db2gse.ST_PointFromText('point (10.02 20.01)',db2gse.coordref()..srid(0)))
 
INSERT INTO CONVEXHULL_TEST
VALUES('Linestring',
       db2gse.ST_LineFromText('linestring  (10.02 20.01,10.32 23.98,11.92 25.64)',
                    db2gse.coordref()..srid(0)))
 
INSERT INTO CONVEXHULL_TEST
VALUES('Polygon',
       db2gse.ST_PolyFromText('polygon ((10.02 20.01,11.92 35.64,25.02 34.15,
                               19.15 33.94,10.02 20.01))',
                    db2gse.coordref()..srid(0)))
 
INSERT INTO CONVEXHULL_TEST
VALUES('Multipoint',
       db2gse.ST_MPointFromText('multipoint (10.02 20.01,10.32 23.98,11.92 25.64)',
                      db2gse.coordref()..srid(0)))
 
INSERT INTO CONVEXHULL_TEST
VALUES('Multilinestring',
       db2gse.ST_MLineFromText('multilinestring ((10.02 20.01,10.32 23.98,11.92 25.64),
                                       (9.55 23.75,15.36 30.11))',
                     db2gse.coordref()..srid(0)))
 
INSERT INTO CONVEXHULL_TEST
VALUES('Multipolygon',
       db2gse.ST_MPolyFromText('multipolygon (((10.02 20.01,11.92 35.64,25.02 34.15,
                                      19.15 33.94,10.02 20.01)),
                                    ((51.71 21.73,73.36 27.04,71.52 32.87,
                                      52.43 31.90,51.71 21.73)))',
                     db2gse.coordref()..srid(0)))

The following SELECT statement lists the subclass name stored in the GEOTYPE column and the convex hull. The convexhull generated by the ST_ConvexHull function is converted to text by the ST_AsText function. It is then cast to a varchar(256) because the default output of ST_AsText is varchar(4000).

SELECT GEOTYPE, CAST(db2gse.ST_AsText(db2gse.ST_ConvexHull(G1))) as varchar(256) 
"The convexhull"
FROM CONVEXHULL_TEST


[ Top of Page | Previous Page | Next Page ]