The ST_Centroid() function

The ST_Centroid() function takes a polygon or multipolygon and returns the geometric center of the bounding box of the polygon or multipolygon as a point.

Syntax

ST_Centroid(pl1 ST_Polygon)
ST_Centroid(mpl1 ST_MultiPolygon)

Return type

ST_Point

Example

The city GIS technician wants to display the building footprint multipolygons as single points in a building density graphic.

The building footprints are stored in the buildingfootprints table that was created with the following CREATE TABLE statement:
CREATE TABLE buildingfootprints (building_id  integer,
                                 lot_id       integer,
                                 footprint    ST_MultiPolygon);
The ST_Centroid() function returns the centroid of each building footprint multipolygon:
SELECT building_id, ST_Centroid(footprint) Centroid
   FROM buildingfootprints;


building_id  506
centroid     1000 POINT (12.5 49.5) 

building_id  543
centroid     1000 POINT (32 51.5) 

building_id  1208
centroid     1000 POINT (12.5 30.5) 

building_id  178
centroid     1000 POINT (32 28.5)