Computes the centroid of a Geometry of any dimension. If the geometry is nomimally of higher dimension, but contains only components having a lower effective dimension (i.e. zero length or area), the centroid will be computed appropriately.
Algorithm
-
Dimension = 2 - 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.
-
Dimension = 1 - Computes the average of the midpoints of all line segments weighted by the segment length.
-
Dimension = 0 - Compute the average coordinate over all points.
If the input geometries are empty, a null
Coordinate is returned.