I need to label some wells with their ID and the sulfate concentrations from multiple sampling events. I started by labeling the wells from just one event, I wrote a python expression that would label a well with its name and the sulfate concentration in red if its over 300,000. The expression has no errors but it labels all the sulfate concentrations in red regardless of the number. It also breaks up the label wherever there is a comma. I know I could do this in SQL, but eventually I need to add multiple sulfate concentrations to this label.
def FindLabel ( [Well_Nme], [Sulfate_9_2016] 😞
if ([Sulfate_9_2016]) >300000:
return [Well_Nme] +'\r\n'+ "<CLR red='255'>" + [Sulfate_9_2016] + "</CLR>"
elif [Sulfate_9_2016] <300000:
return [Well_Nme]+'\r\n'+ [Sulfate_9_2016]
You might like to "Define classes of features and label each class differently" from Layer Properties.
1. Choose the above method.
2. Add a new class. Define a class name.
3. Define a SQL query (Sulfate_9_2016 >300000)
4. Write the appropriate expression.
5. Choose appropriate symbology.
If you want to stick with a script:
def FindLabel ( [Well_Nme], [Sulfate_9_2016] ):
lbl = [Well_Nme] + "\r\n"
if float([Sulfate_9_2016]) > 300000:
lbl = lbl + "<CLR red='255'>" + [Sulfate_9_2016] + "</CLR>"
else:
lbl = lbl + "<CLR red='0'>" + [Sulfate_9_2016] + "</CLR>"
return lbl