Groups a set of geometry objects by intersection connectivity and returns the result as an array of GeometryCollection objects. Each GeometryCollection contains one cluster of mutually intersecting geometries.
Syntax
geometry[] ST_ClusterIntersecting(geometry set g)Parameters
| Parameter | Description |
|---|---|
g | The geometry dataset to cluster. |
Example
The following example clusters three geometries. The two LINESTRING objects share a point, so they form one cluster. The isolated POINT forms a second cluster.
SELECT ST_AsText(unnest(ST_ClusterIntersecting(geom)))
from (select ARRAY['LINESTRING (0 0,0 1)'::geometry,
'LINESTRING (0 1,3 3)'::geometry,
'POINT (-1 -1)'::geometry] as geom) as test;Output:
st_astext
-------------------------------------------------------------
GEOMETRYCOLLECTION(LINESTRING(0 0,0 1),LINESTRING(0 1,3 3))
GEOMETRYCOLLECTION(POINT(-1 -1))
(2 rows)该文章对您有帮助吗?