[Qgis-developer] Centroid and centroid fill

Martin Dobias wonder.sk at gmail.com
Fri Oct 21 14:12:30 EDT 2011


On Thu, Oct 20, 2011 at 10:42 AM, Carson Farmer <carson.farmer at gmail.com> wrote:
> Hi Paolo,
>> I just noticed that the centroid, as calculated by fTools, is not in the
>> same location as the centroid shown by the centroid fill. The difference is
>> easily explained in the case of multipolygons, much less obvious in case of
>> a compact single poligon.
> IIRC, the centroid as returned by fTools is based on the GEOS centroid
> calculation, whose documentation states:
> Based on the usual algorithm for calculating the centroid as a
> weighted sum of the centroids of a decomposition of the area into
> (possibly overlapping) triangles. The algorithm has been extended to
> handle holes and multi-polygons. See
> http://www.faqs.org/faqs/graphics/algorithms-faq/ for further details
> of the basic approach.
>
> Not sure how the centroid fill centroid is calculated, but obviously
> not the same?

The centroid fill uses the same formula. The differences are:
1. centroid fill calculates the centroid for each polygon of
multipolygon separately
2. centroid fill takes into account the polygons clipped to area
visible for rendering
3. centroid fill does not consider holes.

The behavior of 1,2 is forced by the way how symbology works. The item
3 can be handled.

Martin


More information about the Qgis-developer mailing list