The ST_PointOnSurface() function
The ST_PointOnSurface() function takes an ST_Polygon or ST_MultiPolygon and returns an ST_Point guaranteed to lie on its surface.
Syntax
ST_PointOnSurface (pl1 ST_Polygon)
ST_PointOnSurface (mpl1 ST_MultiPolygon)
Return type
ST_Point
Example
The city engineer wants to create a label point for each building footprint.
The buildingfootprints table
that was created with the following CREATE TABLE statement stores
the building footprints:
CREATE TABLE buildingfootprints (building_id integer,
lot_id integer,
footprint ST_MultiPolygon);
The ST_PointOnSurface() function
generates a point that is guaranteed to be on the surface of the building
footprints:
SELECT building_id, ST_PointOnSurface(footprint)
FROM buildingfootprints;
building_id 506
(expression) 1000 POINT (12.5 49.5)
building_id 543
(expression) 1000 POINT (32 52.5)
building_id 1208
(expression) 1000 POINT (12.5 27.5)
building_id 178
(expression) 1000 POINT (32 30)