[postgis-users] st_centroid Points not on Polygon

Nicolas Ribot nicky666 at gmail.com
Mon May 4 07:51:23 PDT 2009


> Ah yes, a classic case of RTFM.
>
> Is this acceptable behavior for this function? Could PostGIS deal with this
> internally to do a post process st_pointonsurface when the centroid is not
> within the polygon.

Yes, indeed, perfectly acceptable, as it corresponds to the
mathematical definition of the centroid, or center of masses, that is
not necessarily on the surface of the object.
It is important, for other applications, that the result is truely the centroid.

That's why pointOnSurface (often confused with centroid) was added,
beside centroid.

>
> For now I guess I will just write a wrapper function for ( CASE WHEN
> st_within(st_centroid(), poly) then st_centroid() else st_pointonsurface()
> END )
>



More information about the postgis-users mailing list