ST_PointOnSurface function

The ST_PointOnSurface function takes a surface or a multisurface as an input parameter and returns a point that is guaranteed to be in the interior of the surface or multisurface. This point is the paracentroid of the surface.

The resulting point is represented in the spatial reference system of the specified surface or multisurface.

If the specified surface or multisurface is null or is empty, then null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramST_PointOnSurface(surface)

Parameter

surface
A value of type ST_Surface, ST_MultiSurface, or one of their subtypes that represents the geometry for which a point on the surface is returned.

Return type

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.


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 125)                                                        
          2 POINT (23 17)