Skip to main content

ST_CENTROID

Introduced or updated: v1.2.895

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)
╰────────────────────────────────────────────────────────────╯
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today