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

ValiSystem vali.system at free.fr
Thu Jun 14 05:36:29 PDT 2007


On 14 juin 07, at 13:02, Matt Doughty wrote:

> Hi,
>
>
>
> 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?
>
>
>
> Cheers,
>
>
>
> Matt

		Matt,

	I don't know the algorithm, but you're right, centroid is not  
necessary inside polygon if it is convex, with interior rings  
(centroid inside a interior ring) or a (i did not check myself) multi- 
polygon. As far as i can see, the centroid is a straight forward  
barycenter (mean of all points), and therefore you cannot really use  
it as a "center point" in a user interface (to place a GUI element  
for a polygon that is not inside polygon confuses the user).
	I agree, having a function that would give a kind of centroid  
guaranteed to be inside the polygon, and in a "natural way" (eg  
equidistant from edges) would be very nice.

Regards



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070614/8e144d85/attachment.html>


More information about the postgis-users mailing list