PostGISGeometry Processing

ST_PointOnSurface

What is ST_PointOnSurface?

ST_PointOnSurface is a PostGIS function that returns a Point that is guaranteed to lie on the input geometry. For a polygon that means strictly inside; for a line, on the line; for a point, the point itself. Unlike the centroid, the result never falls outside the feature.

SQL
ST_PointOnSurface(geometry g1)geometry

The exact position is not geometrically meaningful beyond the "inside" guarantee — it is chosen for computational simplicity, not visual centrality.

When would you use ST_PointOnSurface?

Use ST_PointOnSurface when you need a representative point that must be inside the feature — for label placement on concave or doughnut-shaped polygons, for click-to-select interactions, or for creating a guaranteed-inside seed point for further processing. It is the safer alternative to ST_Centroid for irregular geometries.

SQL
1SELECT country, ST_PointOnSurface(geom) AS label_anchor
2FROM world_countries;

FAQs

When should I prefer this over ST_Centroid?

Use ST_PointOnSurface whenever the point must lie inside the geometry — for example labelling concave shapes where the centroid can fall outside the polygon, or placing interactive markers that users will click. Use ST_Centroid when you want the statistical or geometric centre.

Is the result visually central?

Not usually. The algorithm picks a point that is cheap to compute and guaranteed to be inside — it may be near a boundary or in a narrow arm of the polygon. For the most "inside" point, use ST_MaximumInscribedCircle and take its centre.

What does it return for a LineString?

A point on the line (typically a vertex). For a MultiLineString it returns a point on one of the constituent lines.

How does it behave on empty input?

Returns POINT EMPTY. The function never errors for valid empty geometries — always check ST_IsEmpty before assuming the result is usable.