Centroid

object Centroid

Computes the centroid of a {link Geometry} of any dimension. If the geometry is nominally of higher dimension, but has lower <i>effective</i> dimension (i.e. contains only components having zero length or area), the centroid will be computed as for the equivalent lower-dimension geometry. If the input geometry is empty, a <code>null</code> Coordinate is returned.

== Algorithm ==

  • <b>Dimension 2</b> - the centroid is computed as the weighted sum of the centroids of a decomposition of the area into (possibly overlapping) triangles. Holes and multipolygons are handled correctly. See <code>http://www.faqs.org/faqs/graphics/algorithms-faq/</code> for further details of the basic approach.

  • <b>Dimension 1</b> - Computes the average of the midpoints of all line segments weighted by the segment length. Zero-length lines are treated as points.

  • <b>Dimension 0</b> - Compute the average coordinate for all points. Repeated points are all included in the average.

Version

1.7

Companion
class
class Object
trait Matchable
class Any

Value members

Concrete methods

Computes the centroid point of a geometry.

Computes the centroid point of a geometry.

Value Params
geom

the geometry to use return the centroid point, or null if the geometry is empty