Name

ST_ClusterIntersecting — 聚合函数,用于将输入几何图形聚集到相连的集合中。

Synopsis

geometry[] ST_ClusterIntersecting(geometry set g);

描述

ST_ClusterIntersecting是一个聚合函数,它返回GeometryCollection数组,其中每个GeometryCollection表示一组相互连接的几何图形。

可用性:2.2.0

示例

WITH testdata AS
  (SELECT unnest(ARRAY['LINESTRING (0 0, 1 1)'::geometry,
                       'LINESTRING (5 5, 4 4)'::geometry,
                       'LINESTRING (6 6, 7 7)'::geometry,
                       'LINESTRING (0 0, -1 -1)'::geometry,
                       'POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))'::geometry]) AS geom)

SELECT ST_AsText(unnest(ST_ClusterIntersecting(geom))) FROM testdata;

--result

st_astext
---------
GEOMETRYCOLLECTION(LINESTRING(0 0,1 1),LINESTRING(5 5,4 4),LINESTRING(0 0,-1 -1),POLYGON((0 0,4 0,4 4,0 4,0 0)))
GEOMETRYCOLLECTION(LINESTRING(6 6,7 7))
        

另请参阅

ST_ClusterDBSCAN, ST_ClusterKMeans, ST_ClusterWithin