Export (0) Print
Expand All
Expand Minimize

STCentroid (geometry Data Type)

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


.STCentroid ( )

SQL Server return type: geometry

CLR return type: SqlGeometry

Open Geospatial Consortium (OGC) type: Point

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

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();
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft