Delen via


STCentroid (geometry Data Type)

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

Syntax

.STCentroid ( )

Return Types

SQL Server return type: geometry

CLR return type: SqlGeometry

Open Geospatial Consortium (OGC) type: Point

Remarks

STCentroid() returns null if the geometry instance is not a Polygon or MultiPolygon type.

Examples

The following example uses STCentroid() to create a polygongeometry instance and compute its centroid.

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

Other Resources