📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

ST_CENTROID



Returns the centroid of a GEOMETRY object.

This function only supports GEOMETRY values.

Syntax

ST_CENTROID(<geometry>)

Arguments

ArgumentsDescription
<geometry>The argument must be an expression of type GEOMETRY.

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) │ ╰────────────────────────────────────────────────────────────╯

Was this page helpful?