ST_Centroid¶
Returns the centroid of a geometry or geography.
Usage¶
geometry ST_Centroid(geom: geometry)
geography ST_Centroid(geog: geography)
Arguments¶
- geog (geography): Input geography
- geom (geometry): Input geometry
Description¶
For geography, the centroid is calculated using spherical geometry.
Examples¶
SELECT ST_Centroid(
ST_GeomFromWKT('LINESTRING (-64 45, 52 8)')
);
┌────────────────────────────────────────────────────────────────┐
│ st_centroid(st_geomfromwkt(Utf8("LINESTRING (-64 45, 52 8)"))) │
│ geometry │
╞════════════════════════════════════════════════════════════════╡
│ POINT(-6 26.5) │
└────────────────────────────────────────────────────────────────┘
SELECT ST_Centroid(
ST_GeogFromWKT('LINESTRING (-64 45, 52 8)')
);
┌────────────────────────────────────────────────────────────────┐
│ st_centroid(st_geogfromwkt(Utf8("LINESTRING (-64 45, 52 8)"))) │
│ geography │
╞════════════════════════════════════════════════════════════════╡
│ POINT(8.947787472210084 42.27164424107285) │
└────────────────────────────────────────────────────────────────┘