ST_PointOnSurface
ST_PointOnSurface takes a polygon or a multipolygon as an input parameter and returns a point that is guaranteed to be in the interior of the polygon or multipolygon. This point is the paracentroid of the polygon.
The resulting point is represented in the spatial reference system of the given polygon or multipolygon.
If the given polygon or multipolygon is null or is empty, then null is returned.
Syntax
Parameter
- geometry
- A value of type ST_Polygon or ST_MultiPolygon that represents the geometry for which a point is returned.
Return type
db2gse.ST_Point
Example
In the following example, two polygons are created and then ST_PointOnSurface is used. One of the polygons has a hole in its center. The returned points are on the surface of the polygons. They are not necessarily at the exact center of the polygons.
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_polys (id INTEGER, geometry ST_Polygon)
INSERT INTO sample_polys
VALUES (1,
ST_Polygon ('polygon ( (40 120, 90 120, 90 150, 40 150, 40 120) ,
(50 130, 80 130, 80 140, 50 140, 50 130) )' ,0) )
INSERT INTO sample_polys
VALUES (2,
ST_Polygon ('polygon ( (10 10, 50 10, 10 30, 10 10) )', 0) )
SELECT id, CAST (ST_AsText (ST_PointOnSurface (geometry) ) AS VARCHAR(80) )
POINT_ON_SURFACE
FROM sample_polys
Results:
ID POINT_ON_SURFACE
----------- ------------------------------------
1 POINT ( 65.00000000 125.00000000)
2 POINT ( 30.00000000 15.00000000)
