Table of Contents

Class Centroid

Namespace
NetTopologySuite.Algorithm
Assembly
NetTopologySuite.dll

Computes the centroid of a Geometry of any dimension. For collections the centroid is computed for the collection of non-empty elements of highest dimension. The centroid of an empty geometry is null

public class Centroid
Inheritance
Centroid
Inherited Members

Remarks

Algorithm

  • Dimension 2 - the centroid ic computed as a weighted sum of the centroids of a decomposition of the area into (possibly overlapping) triangles. Holes and multipolygons are handled correctly. 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. Zero-length lines are treated as points.
  • Dimension 0 - Compute the average coordinate over all points. Repeated points are all included in the average
If the input geometries are empty, a null Coordinate is returned.

Constructors

Centroid(Geometry)

Creates a new instance for computing the centroid of a geometry

public Centroid(Geometry geom)

Parameters

geom Geometry

Methods

GetCentroid()

Gets the computed centroid.

public Coordinate GetCentroid()

Returns

Coordinate

The computed centroid, or null if the input is empty

GetCentroid(Geometry)

Computes the centroid point of a geometry.

public static Coordinate GetCentroid(Geometry geom)

Parameters

geom Geometry

The geometry to use

Returns

Coordinate

The centroid point, or null if the geometry is empty