ST_CENTROID
Returns the centroid of a GEOMETRY object.
This function only supports GEOMETRY values.
Syntax
ST_CENTROID(<geometry>)
Arguments
Return Type
GEOMETRY.
Examples
SELECT ST_ASWKT(ST_CENTROID(TO_GEOMETRY('POINT(1 2)')));
╭──────────────────────────────────────────────────╮
│ st_aswkt(st_centroid(to_geometry('POINT(1 2)'))) │
├──────────────────────────────────────────────────┤
│ POINT(1 2) │
╰──────────────────────────────────────────────────╯
SELECT ST_ASWKT(ST_CENTROID(TO_GEOMETRY('LINESTRING(0 0, 2 0)')));
╭────────────────────────────────────────────────────────────╮
│ st_aswkt(st_centroid(to_geometry('LINESTRING(0 0, 2 0)'))) │
├────────────────────────────────────────────────────────────┤
│ POINT(1 0) │
╰────────────────────────────────────────────────────────────╯