Table of Contents

Class SpatialCentroid

Namespace
YndigoBlue.Velocity.Functions
Assembly
YndigoBlue.Velocity.dll

Represents the ST_Centroid spatial analysis function that computes the geometric center of a geometry.

public class SpatialCentroid : Function, IElement, ICheckItem, IDefaultItem, IFilterItem
Inheritance
SpatialCentroid
Implements

Remarks

Warning

Spatial functions are not available in the Community Edition of Velocity. They require the Full Edition.

The ST_Centroid function returns a point representing the mathematical centroid (center of mass) of the input geometry. For polygons, this is the center of gravity assuming uniform density. For lines, it's the center of the line's extent. For multi-part geometries, it's the weighted center of all parts. Note that the centroid may not lie within the geometry itself (e.g., for C-shaped polygons). Useful for labeling, finding centers, or proximity analysis. OGC-compliant.

SpatialCentroid diagram showing geometric centers

Return Type: Always returns a POINT geometry.

Example Results (using test geometries):

ShapeCentroid
PY0 (4°×4° square)POINT(-98 42) - center of rectangle
PY1 (0.5°×1° rectangle)POINT(-98.25 41.5) - center of rectangle
PY2 (1°×3° rectangle)POINT(-93.5 40.5) - center of rectangle
PY3 (triangle)POINT(-95.33 41.5) - centroid of triangle
PY4 (2°×1.5° rectangle)POINT(-100 44.25) - center of rectangle
LN1 (vertical line)POINT(-97 42) - midpoint of line
PT1, PT2 (points)Returns the point itself

Constructors

SpatialCentroid(Geometry)

Initializes a new instance of ST_Centroid with a geometry literal.

SpatialCentroid(Column)

Initializes a new instance of ST_Centroid with a spatial column.

SpatialCentroid(Function)

Initializes a new instance of ST_Centroid for a function result (e.g., from another spatial operation).

SpatialCentroid(Geography)

Initializes a new instance of ST_Centroid with a geography literal.