Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
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
    
yes, a single table exists, it has simple points with geometries all in the same column –  EnE_ Jul 4 '12 at 14:07
add comment

2 Answers

up vote 6 down vote accepted

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
share|improve this answer
add comment

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.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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