I've written some code in Python and PostGIS to find duplicate geometric features within the same feature layer.
That part is a success. The problem I have is the dupes as well as the original feature IDs are part of the result of my cursor.execute command.
What's the best way for me to segregate the first occurrence of a feature geometry from subsequent occurrences of the same geometry?
#Select all features within current layer (i.e. HydrographySrf)
cmd = "SELECT * FROM " + layer
cursor.execute(cmd)
numLayer = cursor.rowcount
#find all duplicates in the current layer
cmd = "SELECT b.ogc_fid FROM " + layer + " AS a, " + layer + " AS b WHERE ST_Equals(a.geom, b.geom) AND a.ctid <> b.ctid"
cursor.execute(cmd)
if (cursor.rowcount > 0):
#Store Suspect Feature IDs for Reporting at End of Logfile
for row in sorted(cursor):
if row[0] not in discoveredFeatureIntegerIDs:
discoveredFeatureIntegerIDs.append(row[0])