简体   繁体   English

如何在postGIS中查找重叠点

[英]How to find overlapped points in postGIS

I have a set of point dataset in postgis with xcoordinate and ycordinate. 我在postgis中有一组带有xcoordinate和ycordinate的点数据集。 There are few points which overlapped with each other as they are having same xcoordinate and ycoordniate. 因为它们具有相同的x坐标和yordordniate,所以很少有相互重叠的点。 How to find the overlapped points using query in postgresql? 如何在Postgresql中使用查询查找重叠点?

There are at least two ways to find duplicate records using aggregate functions. 至少有两种方法可以使用聚合函数查找重复记录。 Assume a table my_table with geometry column geom and primary key gid : 假设表my_table包含几何列geom和主键gid

First, using a HAVING statement, and collecting the primary keys with array_agg : 首先,使用HAVING语句,并使用array_agg收集主键:

SELECT array_agg(gid), count(*)
FROM my_table
GROUP BY geom
HAVING count(gid) > 1;

Second, using a WINDOW to count the partitions. 其次,使用WINDOW来计数分区。

WITH data AS (
  SELECT gid, count(*) OVER (PARTITION BY geom)
  FROM my_table
)
SELECT * FROM data WHERE count > 1;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM