ST_Centroid
Determine the geometric center of a geometry.
The geometric center of the geometry is the "average" of the points in the geometry. The result is not guaranteed to be on the geometry. If the geometry is empty, an empty point is returned.
Syntax
ST_Centroid(geo);
- geo
- The input geometry.
Type: ST_GEOMETRY(ANY)
Returns
A value of type ST_GEOMETRY(126) that contains a point geometry.
Examples
inza..ST_AsText(inza..ST_Centroid(inza..ST_WKTToSQL('LINE STRING (0 0, 10 0)')));
ST_ASTEXT
---------
POINT (5 0)
(1 row)
SELECT inza..ST_AsText(inza..ST_Centroid(inza..ST_WKTToSQL('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))')));
ST_ASTEXT
-----------
POINT (5 5)
(1 row)
SELECT
inza..ST_AsText(inza..ST_Centroid(inza..ST_WKTToSQL('POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10))')));
ST_ASTEXT
-----------
POINT (15 15)
(1 row)