Python label expression adding text & fields

1215
4
07-06-2018 07:08 AM
DamonOsbourne
New Contributor II

Need python label expression to label linear assets in Arcmap 10.3 with length (rounded to nearest whole number) with a foot symbol(') at the end, plus a space, then text from a different field.  Have this so far: round(float( [LLENGTH]), 0)

0 Kudos
4 Replies
DanPatterson_Retired
MVP Emeritus

don't know about 10.3 or vb but in python and recent versions

leng = 7.4

fld = 'from field'

result = "{}' {}".format(round(leng), fld)

print(result)

7' from field
DamonOsbourne
New Contributor II

Thanks, I may have tagged the question incorrectly, looking for label expression syntax for the Maplex Label Engine in Arcmap

0 Kudos
MitchHolley1
MVP Regular Contributor

Damon,

Dan has given the correct Python Label Expression in line 5 of his example.  The first variable will be the LENGTH field, and the second is whatever other text field you chose.

You may have to convert the length field to a float first (line 3).

"{}' {}".format(round(leng), fld)"{}' {}".format(round(float(leng)), fld)‍‍‍‍

DamonOsbourne
New Contributor II

Works great.  Thanks!

0 Kudos