I need to create a model in the ArcGIS ModelBuilder. I am working with a feature class of zip-codes for a state. I have got to the point where the zip-codes that have duplicates are selected from the feature class. There is a field called "Spots" within this feature class that has numeric values from 0-10. Of the zip-codes that have duplicates, I want to delete the feature that has the smaller number in the "Spots" field. Furthurmore, if the spots field is the same for the duplicates, I'd like to keep only the bottom row. I hope this makes sense! Any help would be great!

1 Answer 1


I've had very little luck with model builder on tasks simpler than this. I'd use arcpy, its a lot more powerful and user-friendly. For your task I'd try something like this...

import arcpy
shp = 'yourZipcodeShapefile'
rows = arcpy.SearchCursor(shp)
field = 'yourZipcodeField'
#Create iterable list of zipcodes
ziplist = []
for row in rows:
    val = row.GetValue(field)
#remove duplicate zipcodes from iterator list
ziplist = list(set(ziplist))
#Start processing
for zip in ziplist:
    query = '"'+field+'"='+str(zip)
    arcpy.SelectLayerByAttribute(shp, field, query)
    rows = arcpy.UpdateCursor(shp,'Spots')
    #now here comes the tricky part, because I'm not exactly sure what you're looking for
    #So at this point we should have multiple duplicates of a zipcode selected, and we want to rid ourselves of unwanted duplicate features based on a query of values in the 'Spots' field
    for row in rows:
        if row[0]<row[1]:
        elif row[0]>row[1]:
        elif row[0]=row[1]:

Someone else might have something to say about that last codeblock, but its a good start. Honestly though, I needlessly banged my head against the keyboard trying to use Model Builder until I realized python is way better. Python is a great skill to learn! Give it a try, you'll be surprised.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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