[postgis-users] How is Centroid(Geometry) calculated?

Obe, Regina robe.dnd at cityofboston.gov
Thu Jun 14 04:52:03 PDT 2007

It uses the Geos library to calculate centroid if Geos is installed.  My
cursory glance of the Geos code,  looks to me like for polygons and
 it first takes the area of the region and then finds the average x,y, z
of that encompassing area.
So yes it is conceivable in a multipolygon that the centroid may not
fall in any of the polygons.
Anyone correct me if I am wrong since I'm not too familiar with c++
Anyrate I think the relevant piece of code in geos library is
Hope that helps,


From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Matt
Sent: Thursday, June 14, 2007 7:03 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] How is Centroid(Geometry) calculated?



Can anybody explain how PostGIS calculates centroids? I've checked the
manual but the relevant section doesn't refer to an OGC Specification.
From what I can understand, it takes an average of the coordinates of
all the vertices of an entry, ignoring whether or not the centroid falls
outside the polygons. Is this right? This differs from other GIS-
GeoMedia, for example, when confronted with a multipolygon entry, always
puts the centroid inside the largest polygon.


Can anybody shed some light on this?







Matt Doughty



Tel.:  +34 945 13 13 72    652 77 14 15

Fax: +34 945 23 03 40 




The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070614/08809bfd/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 3743 bytes
Desc: image001.jpg
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070614/08809bfd/attachment.jpg>

More information about the postgis-users mailing list