ST_Centroid()¶
TL;DR¶
Use ST_Centroid() to return the centroid point of a supported geometry.
Returns the centroid point of a supported geometry.
Syntax¶
ST_Centroid(geom)
Arguments¶
Argument |
Description |
|---|---|
|
A |
Return Value¶
Returns the same geometry precision type as geom.
Usage Notes¶
Current source tests support POINT, LINESTRING, and POLYGON; MULTIPOINT is rejected. The result preserves SRID metadata. Source:
test/distributed/cases/geo/geo_functions_unary.sql,geo_srid.sql.
Examples¶
DROP DATABASE IF EXISTS geo_accessor_demo;
CREATE DATABASE geo_accessor_demo;
USE geo_accessor_demo;
SELECT ST_AsText(ST_Centroid(ST_GeomFromText('POLYGON((0 0,2 0,2 2,0 2,0 0))'))) AS centroid;
DROP DATABASE geo_accessor_demo;