HOW TO
It is usual for an attribute table to contain fields with common values and unique values. So, it is sometimes necessary to identify duplicate values to create a group among layers, or to identify unique values to isolate the feature.
There are four different ways to identify duplicate values:
Using the Find Identical tool
The Find Identical tool creates a new stand-alone table. The tool identifies the ObjectID of a feature and creates two columns, one containing the ObjectID value of the selected feature and the other containing numbers to mark an identical or unique feature. Identical records have the same FEAT_SEQ value, while non-identical records have sequential value. FEAT_SEQ values have no relationship to IDs of input records. Refer to ArcGIS Pro: Find Identical (Data Management) for more information.
Using the Calculate Field function
The isDuplicate() Python parser function can populate a new field to identify a value as duplicate or unique by assigning a specific value. For example, unique values and the first occurrence of multiple values are populated with 0, and all duplicate values are marked with a value of 1. The following steps describe how to apply the function for this purpose:
isDuplicate(!Field_Name_To_Verify!)
uniqueList = [] def isDuplicate(inValue): if inValue in uniqueList: return 1 else: uniqueList.append(inValue) return 0
Using a stand-alone Python script
The script creates a new field and populates the field with the number of duplicate values.
import arcpy
arcpy.env.workspace=r"D:\test.gdb" infeature="sample_feature" field_in="sample_field" field_out="COUNT_"+field_in arcpy.AddField_management(infeature,field_out,"SHORT")
lista=[] cursor1=arcpy.SearchCursor(infeature) for row in cursor1: i=row.getValue(field_in) lista.append(i) del cursor1, row
cursor2=arcpy.UpdateCursor(infeature) for row in cursor2: i=row.getValue(field_in) occ=lista.count(i) row.setValue(field_out,occ) cursor2.updateRow(row) del cursor2, row print ("Done.")
The following shows the full code:
import arcpy arcpy.env.workspace=r"D:\test.gdb" infeature="sample_feature" field_in="sample_field" field_out="COUNT_"+field_in arcpy.AddField_management(infeature,field_out,"SHORT") lista=[] cursor1=arcpy.SearchCursor(infeature) for row in cursor1: i=row.getValue(field_in) lista.append(i) del cursor1, row cursor2=arcpy.UpdateCursor(infeature) for row in cursor2: i=row.getValue(field_in) occ=lista.count(i) row.setValue(field_out,occ) cursor2.updateRow(row) del cursor2, row print ("Done.")
Using the Summary Statistics tool, and joining the table
Get help from ArcGIS experts
Download the Esri Support App