Name

ST_MultiCentroid — Returns a centroid for each part of a complex geometry.

Synopsis

geometry MultiCentroid(bytea Geometry);

Alias

MultiCentroid

Description

Returns a centroid for each part of a complex geometry. Thus, a MultiPolygon composed of two Polygons woud have as MultiCentroid a MultiPoint with two Points.

[Note]

GeometryCollections are supported

Coordinate Dimensions
2D3DM
Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
----

Examples

SELECT ST_AsText(ST_MultiCentroid(ST_GeomFromText('
 GEOMETRYCOLLECTION (LINESTRING (0 0, 10 10, 10 5, 15 10),
 MULTIPOLYGON (((-5 20, -5 34, 11 34, 11 20, -5 20)), (
                (14 20, 14 29, 23 29, 23 20, 14 20))))')
));

--Result
MULTIPOINT ((7.976858924576366 6.15123928305091), (3 27), (18.5 24.5))
GeomA
ST_MultiCentroid (GeomA)

Related functions

ST_Centroid