# Name: DeleteIdentical_Example2.py
# Description: Delete identical features in a dataset based on Shape (geometry) and a TEXT field.
# Import system modules
arcpy.env.overwriteOutput = True
# Set workspace environment
arcpy.env.workspace = "C:/data/sbfire.gdb"
# Set input feature class
in_dataset = "fireincidents"
# Set the field upon which the identicals are found
fields = ["Shape", "INTENSITY"]
# Set the XY tolerance within which to identical records to be deleted
xy_tol = "0.02 Miles"
# Set the Z tolerance to default
z_tol = ""
# Execute Delete Identical
arcpy.DeleteIdentical_management(in_dataset, fields, xy_tol, z_tol)
I just want to clarify which order it selects the objects to delete?
Thanks in advance~~~~
Pretty sure in order of the ObjectID; so the feature with the greatest OID value remains. But don't take my word for it; try your script on a couple of identical test features to be sure..
Esri doesn't disclose their exact methodology. In all likelihood, ObjectID/FID is probably used to sort the data set so the lowest OID/FID will be kept and higher marked for deletion. That said, I would not depend on that behavior since it isn't documented, even if it does appear to work that way. The documentation does state that Find Identical—Data Management toolbox | Documentation uses the same methodology, whatever that may be, so you can use Find Identical to see what the results would be from running Delete Identical.
You could do this with a search cursor.
1. Create a dictionary of OID keys and values of [SHAPE@, Intensity, Field]
2.Iterate through each OID to find matching SHAPE@ and Intensity and append them to a list.
3.you should have a list of all OIDs classed as identical by position and Intensity.
Iterate through that list using the initial dictionary to find where field is N or Y