[GIS] PostGIS – Get a point inside a line or polygon

centroidslinestringpolygonpostgis

I need to get the center point of a line or polygon to make marker for my app. So that when you click a marker the geometry appears (line or polygon). I used ST_Centroid to make it work.

The result is what I expected unnest some polygons or lines whichs centroids are out of the geometry. What i would like for those lines or polygons is to get the "most center point" but inside the geometry.

How can I do this? Is there a solution?

Best Answer

From the doc: ST_PointOnSurface — Returns a POINT guaranteed to lie on the surface.

Related Question