Convert Python expression from ArcMap to Arcade in ArcPro

03-11-2022 10:56 AM
Occasional Contributor

I've created hatch marks on a line to use as stationing for a levee feature on a map but I need to format the labels to read like stations rather than just numbers. I'm able to do this in ArcMap (see attached screenshot) using the following expression: 

def FindLabel (esri__measure):
EM = str(int(round(esri__measure)))
if len(EM) == 0:
return "0+00"
elif len(EM) == 1:
return "0+0{0}".format(*EM)
elif len(EM) == 2:
return "0+{0}{1}".format(*EM)
elif len(EM) == 3:
return "{0}+{1}{2}".format(*EM)
elif len(EM) == 4:
return "{0}{1}+{2}{3}".format(*EM)
elif len(EM) == 5:
return "{0}{1}{2}+{3}{4}".format(*EM)
elif len(EM) == 6:
return "{0}{1}{2}{3}+{4}{5}".format(*EM)

Now I have to do the same thing but in ArcPro and I'm only given the option to do this using Arcade. Does anybody know how I can convert the expression/script above from Python to Arcade? I'm a novice at both languages so any help would be much appreciated!



0 Kudos
4 Replies
MVP Frequent Contributor

Label class properties in Pro should let you pick Python to use the existing code.




Occasional Contributor

Thanks for replying but that is not the window I see when I label the hatch marks.Expression_Builder.jpg

0 Kudos
Occasional Contributor

My team lead showed me this post that solved my problem.

Solved: Stationing lines in ArcGIS Pro - Esri Community

0 Kudos
Occasional Contributor

Now that I've figured this out, does anybody know how I would convert these to annotation? Now that the levee station numbers have been generated, I can't figure out how to rotate them into place. I'd like to convert the numbers to annotation but I can't find how to do that since the station numbers are not true labels since they are not based on attribute table values.

Levee Station Placement.JPG

0 Kudos