I am using ArcGIS Desktop 10.3.
I have a number of polygons representing exploration licences and a series of attributes including licence name, operator, partners and associated interests (%) within each licence. I am trying to create a stacked label expression that will display in the following order: Licence name, operator and interest, partner(s) name and interest. The way the attribute table is setup is that the percentage interest values are 0 where there is no partner. The dataset is read only and so I can't edit the table to remove the zeros. So far I have the following code:
def FindLabel ([AREABLK] , [Own1] , [Asgnpct1] , [Own2] , [Asgnpct2] , [Own3] , [Asgnpct3] , [Own4] , [Asgnpct4] , [Own5] , [Asgnpct5]):
if [Own5] is not None:
return [AREABLK] + "\n" + [Own1] + " (" + [Asgnpct1] + "%" + ")" + "\n" + [Own2] + " (" + [Asgnpct2] + "%" + ")" + "\n" + [Own3] + " (" + [Asgnpct3] + "%" + ")" + "\n" + [Own4] + " (" + [Asgnpct4] + "%" + ")" + "\n" + [Own5] + " (" + [Asgnpct5] + "%" + ")"
elif ([Own4] is not None and [Own5] is None):
return [AREABLK] + "\n" + [Own1] + " (" + [Asgnpct1] + "%" + ")" + "\n" + [Own2] + " (" + [Asgnpct2] + "%" + ")" + "\n" + [Own3] + " (" + [Asgnpct3] + "%" + ")" + "\n" + [Own4] + " (" + [Asgnpct4] + "%" + ")"
elif ([Own3] is not None and [Own4] is None):
return [AREABLK] + "\n" + [Own1] + " (" + [Asgnpct1] + "%" + ")" + "\n" + [Own2] + " (" + [Asgnpct2] + "%" + ")" + "\n" + [Own3] + " (" + [Asgnpct3] + "%" + ")"
elif ([Own2] is not None and [Own3] is None):
return [AREABLK] + "\n" + [Own1] + " (" + [Asgnpct1] + "%" + ")" + "\n" + [Own2] + " (" + [Asgnpct2] + "%" + ")"
elif [Own2] is None:
return [AREABLK] + "\n" + [Own1] + " (" + [Asgnpct1] + "%" + ")"
This gives the following output:
The first few rows work fine but where the partner isn't present it still shows the 0 value with the (%) text added.
I would therefore like to ignore the 0 values where there is no partner in the expression.
return "{0}\n{1} ({2}%)\n{3} ({4}%)\n{5} ({6}%)\n{7} ({8}%)\n{9} ({10}%)".format([AREABLK], [Own1], [Asgnpct1], [Own2], [Asgnpct2], [Own3], [Asgnpct3], [Own4], [Asgnpct4], [Own5], [Asgnpct5])