Appearance
ST_CENTROID
Computes the geometric center (centroid) of a GEOGRAPHY
object.
- For
[MULTI]POINT
objects, the centroid is the arithmetic mean of the input coordinates - For
[MULTI]LINESTRING
objects, the centroid is calculated using the weighted length of each line segment - For
[MULTI]POLYGON
objects, the centroid is determined based on the area
Note: The centroid is not always guaranteed to be within the original shape
Syntax
sql
ST_CENTROID(<input>)
Arguments
<input>
: AGEOGRAPHY
value to compute the centroid of
Returns
Returns a GEOGRAPHY
of subtype ST_Point
representing the centroid.
For mixed-dimension input, the result is equal to the centroid of the component shapes of highest dimension (since the lower-dimension shapes contribute zero "weight" to the centroid).
Example
sql
SELECT ST_AsText(ST_Centroid('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))'::GEOGRAPHY));
-- POINT(1 1)