STCentroid (geometry)

STCentroid (geometry)#

Returns the geometric center of a geometry instance that consists of one or more polygons.

Syntax#

.STCentroid ()

Return type#

geometry

Example#

Compute the centroid of a Polygon instance.

DECLARE @g geometry;
SET @g = geometry::STGeomFromText('POLYGON((0 0, 3 0, 3 3, 0 3, 0 0),(2 2, 2 1, 1 1, 1 2, 2 2))', 0);
SELECT @g.STCentroid().ToString();

See Also#