I have some code that classifies features based on a combination of landuse and "points" assigned across three variables. In running this code, there are 4 classification values to assign, with the last being a catch-all for some miscellaneous cases. I am iterating through a dictionary that holds values for land use, and upper and lower point value limits that affect the classification. I tried using a sequence of if/elif/elif/else statements and if I run it this way, everything gets assigned the catch-all value but if I drop the else statement at the end the code classifies everything correctly except for the miscellaneous features which remain null. Any thoughts as to what is happening? I've found an alternative solution to this but am curious why this approach fails.
field_list = ['LandUse','APD_Points','AFR_Points','CED_Points','TotalPoints','Program']
prop_dict = {'undev':('Undeveloped',10, 20), 'res':('Residential',15,30),'mfam':('Multifamily',80,160),'NR':('Non Residential',40,80),'ED':('Education Facility'),'EX':('Exclude')}
# iterate through dictionary and update attributes with classifcation values based on point ranges and landuse category
for in_arg in prop_dict.values():
ptype = in_arg[0]
llimit = in_arg[1]
ulimit = in_arg[2]
with arcpy.da.UpdateCursor(fc,field_list) as cursor:
for row in cursor:
if (row[0] == ptype and row[2]+row[3] > 0 and (row[1]>=llimit)):
row[5] = 'PGM1 Qualifying'
elif (row[0] == ptype and row[1]>= ulimit):
row[5] = 'PGM2 Qualifying'
elif (row[0] == ptype and row[1] < ulimit):
row[5] = 'Non-Qualifying'
else:
row[5] = 'Public'
cursor.updateRow(row)