I have a Spatialite database with points. From time to time now points are added. What would be the easiest way to remove duplicates based on the coordinates?
Hints are greatly appreciated.
|
I have a Spatialite database with points. From time to time now points are added. What would be the easiest way to remove duplicates based on the coordinates? Hints are greatly appreciated. |
|||
|
|
|
Auto-joining the table would allow you to find duplicates rows. Something like that should work :
if points :
(not tested .....) |
|||||||
|
|
I think the easiest is to never let the duplicate in. add a unique constraint on the geometry field. I don't know how that will work in spatiallite but in postgis the constrint would compare the bounding boxes which will dive the wanted effect in the case of points. if it doesn't matter which one of the duplicates to remove you could build a query that deletes all rows with id that is not found in a subquery which selects the distinct geometries. same here, safe with points but not other types since only the bbox will be compared not the actual geometry (if working the same way as postgis). /Nicklas |
|||
|
|
(taken from the answer of Denis Valeev here: http://stackoverflow.com/questions/3777633/delete-duplicate-rows-dont-delete-all-duplicate) |
||||
|
|