I want to label the source files for a unified shapefile, and there are three respective columns for each. If there is no value in the column, there is no data from that source; if there is a value in multiple columns, it is from multiple sources (and therein lies the problem). I have written the following for use in the Codeblock in field calculator:
def srcfind (grcode,grcode2,lur):
if lur == 'Parks and Recreational' and grcode == 0 and grcode2 == 0:
return 'dmti'
elif lur == 'Parks and Recreational' and grcode > 0 and grcode2 > 0:
if grcode <> 0 and grcode2 <> 0:
return 'dmti, land cover, clutter'
elif grcode == 0 and grcode2 > 0:
return 'dmti and land cover'
elif grcode > 0 and grcode2 == 0:
return 'dmti and clutter'
elif lur <> 'Parks and Recreational' and grcode > 0 and grcode2 == 0:
return 'clutter'
elif lur <> 'Parks and Recreational' and grcode == 0 and grcode2 > 0:
return 'land cover'
elif lur <> 'Parks and Recreational' and grcode > 0 and grcode2 > 0:
return 'clutter and land cover'
The first 'if' works correctly; even the 'dmti, land cover, clutter' category works correctly; and the last three elifs work correctly, it's just the middle part to determine 'dmti and land cover' and 'dmti and clutter' which don't work, resulting in the field being labelled 'land cover' or 'clutter' (depending on which column has a value).
Essentially, how do I fix this?
The image below is the attribute table with the variables labelled. You can see that it doesn't work for the conditions I mentioned.