3

I have a table made of merged point datasets in PostGIS. I want to select all of the features where two or more points have identical geom values.

At present I just want to select so I can review the associated field values.

  • 1
    The geometries are now all in the same column? They're simple points, multipoints or something else? – lynxlynxlynx Jul 4 '12 at 11:09
  • 1
    yes, a single table exists, it has simple points with geometries all in the same column – EnE_ Jul 4 '12 at 14:07
19

Not all the details are clear, but my general approach would be along these lines:

SELECT *
FROM thetable AS a, thetable AS b
WHERE ST_Equals(a.geom, b.geom) AND a.id <> b.id
3

Something like this:

SELECT p1.id, p1.name, p1.<other attrib>, p2.id, p2.name, p2.<other attrib> 
FROM points p1, points p2
WHERE ST_Intersects(p1.geom, p2.geom) AND
p1.id <> p2.id;

Some notes:

  • With a large number of points you'll probably want to implement a spatial index on the table.
  • Also this will find only points that exactly match. Sometimes very small rounding errors can create pairs of points which are essentially overlapping, but the coordinates are different by 0.1 mm or so, and the above will not find that pair. So perhaps wrapping one of the points with a small buffer, or running ST_Dwithin() with a small tolerance might be better.
0

I think this answer can help to find points which overlapped with each other How to find overlapped points in postGIS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.