User's Guide and Reference

ST_Centroid

ST_Centroid takes a polygon or multipolygon and returns its geometric center as a point.

Syntax
db2gse.ST_Centroid(s db2gse.ST_Surface)
db2gse.ST_Centroid(ms db2gse.ST_MultiSurface)

Return type


For surface: db2gse.ST_Point

Examples

The city GIS technician wants to display the multipolygons of the building footprints as single points in a building density graphic.

The building footprints are stored in the BUILDINGFOOTPRINTS table that was created with the following CREATE TABLE statement.

CREATE TABLE BUILDINGFOOTPRINTS (building_id integer,
                                 lot_id      integer,
                                 footprint   db2gse.ST_MultiPolygon); 

The ST_Centroid function returns the centroid of each building footprint multipolygon. The AsBinaryShape function converts centroid point into a shape, the external representation that is recognized by the application.

SELECT building_id,
       CAST(db2gse.AsBinaryShape(db2gse.ST_Centroid (footprint)) as blob(1m)) 
"Centroid"
FROM BUILDINGFOOTPRINTS; 


[ Top of Page | Previous Page | Next Page ]