[postgis-users] Does the centroid function work?

David Blasby dblasby at refractions.net
Wed Oct 9 13:57:26 PDT 2002


Paul Ramsey wrote:

> It is also defined on 'MultiSurface', which has 'MultiPolygon' as a
> child. Basically, any two-dimensional object should have a centroid. The
> 'MultiSurface' definition notes that Centroid() return 'The mathematical
> centroid for this MultiSurface. The result is not guaranteed to be on
> this MultiSurface.'

oops - my mistake.  I check the code - if you send it a multipolygon, it
will take the average of the centroids of each of the sub-polygons.

To get the "centroid" of any object:

SELECT
    centroid( envelope( <any geom>)) ;

dave





More information about the postgis-users mailing list