Class Centroid
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
Inherited Members
Namespace: NetTopologySuite.Algorithm
Assembly: NetTopologySuite.dll
Syntax
public class Centroid
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
null
Coordinate is returned.
Constructors
| Improve this Doc View SourceCentroid(Geometry)
Creates a new instance for computing the centroid of a geometry
Declaration
public Centroid(Geometry geom)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geom |
Methods
| Improve this Doc View SourceGetCentroid()
Gets the computed centroid.
Declaration
public Coordinate GetCentroid()
Returns
Type | Description |
---|---|
Coordinate | The computed centroid, or null if the input is empty |
GetCentroid(Geometry)
Computes the centroid point of a geometry.
Declaration
public static Coordinate GetCentroid(Geometry geom)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geom | The geometry to use |
Returns
Type | Description |
---|---|
Coordinate | The centroid point, or null if the geometry is empty |