I have successfully rendered a stacked label in ArcMap using a java script labeling expression, but I cannot figure out how to do the same thing with Python in the Label Expression box.
This is what I used for java script:
function FindLabel ( [LOT], [SUBDIVISION] )
{
return [LOT] + "\r" + [SUBDIVISION];
}
How do I do this same thing by using python?
I just want to stack the my Lot label on top of my Subdivision label, but using python.
Thank you in advance for any thoughts or suggestions.
Solved! Go to Solution.
Thank you so much for taking the time to respond with such great ideas and examples. I will definitely spend more time with label expressions, using these examples to help me construct more complex labels. I am still quite new to coding, but it is quite satisfying when I can understand some code and when I can write code that produces something, especially with no errors.
Although it sounds like you've already found an answer to the problem, but you could take advantage of try/except to label, or skip, null values:
def FindLabel ( [LOT], [SUBDIVISION] ): try: return [LOT] + "\r" + [SUBDIVISION] except: return 'this had a null value'
Another succinct way to write this is:
def FindLabel ( [LOT], [SUBDIVISION] ):
if [LOT] and [SUBDIVISION]:
return [LOT] + '\r' + [SUBDIVISION]