聚合前
聚合后
具体sql
/* 使用ST_ClusterDBSCAN函数,ST_ClusterDBSCAN是窗口函数用来对数据进行聚簇 第一个参数是字段,第二个参数是距离,他是用的是度,这里写0.000179大约就是20米,minpoints表示多少个聚合才算是一个簇,比如两台车就算是聚集,那就设置为2 */ select ST_Centroid(ST_Collect(zb)), t.cluster_id, count(1) from ( select st_geomfromtext(concat('point(',jd,' ',wd,')')) as zb, ST_ClusterDBSCAN(st_geomfromtext(concat('point(',jd,' ',wd,')')),eps := 1,minpoints := 1) over () as cluster_id from public.yw_jq_hlwrw ) t group by t.cluster_id
推荐使用dbeaver
参考文章:https://blog.csdn.net/dg88534187/article/details/131209244