ST_ClusterIntersecting — 將輸入的幾何圖形聚集成連接集合的彙總函數。
geometry[] ST_ClusterIntersecting(
geometry set g)
;
一個彙總函數,返回一個 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))