We have created auto labels expression for proper case for an ArcMap, Data Driven Page document. I noticed there are some exceptions where the proper case label is not accurate (e.g. Crete-monee Rd, I 355 Nb). It has been awhile since I programmed. I assume I need to add an if-else if-else loop within the For loop (see attachment) to identify the hyphen names and the highway names to rule them out either in separate loops or as exceptions to the remaining names. I could also put those two name types in separate classes of labels to make sure they appear correctly (e.g. FULLNAME like '*-*'). Thoughts?
I think you're on the right track. Does your data only have a FULLNAME attribute or are the address components broken out in other attributes?
Only the FULLNAME attribute.
I don't know what language applies to labelling but in fields if you use the python parser youy should be able to play with this idea
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> <SPAN class="keyword token">import</SPAN> string <SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> z <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Crete-monee Rd, I 355 Nb'</SPAN> <SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> zz <SPAN class="operator token">=</SPAN> z<SPAN class="punctuation token">.</SPAN>casefold<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> zz <SPAN class="string token">'crete-monee rd, i 355 nb'</SPAN> <SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> <SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> string<SPAN class="punctuation token">.</SPAN>capwords<SPAN class="punctuation token">(</SPAN>zz<SPAN class="punctuation token">,</SPAN> sep<SPAN class="operator token">=</SPAN><SPAN class="string token">" "</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="string token">'Crete-monee Rd, I 355 Nb'</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
If I am not mistaken the string module is already imported in the field calculator, if you set the parser to python. I ddon't if string.capwords is in there, but it might be worth a look
You can use python in labelling
Hi Greg,
That makes it tricky. Correcting the casing on the source data might be more worthwhile in the long term, assuming you have control over the data and can do that. Either way, you'll need to parse the components of the FULLNAME value. Are these intersections? I was think that 'Nb' meant New Brunswick but I think it means Northbound.
Assuming that's the case, your FULLNAME components would be (I think):
Street Name ("Crete-Monee")
Street Type ("Rd")
Highway Name ("I 355")
Highway Direction ("NB")
Is that correct? Assuming your data is formatted consistently with the example you gave, it would be possible to parse those components and correct them in the source data. You could use an arcpy.da.Update cursor pretty effectively to do that.
Some questions to consider:
Do you want a hyphen for interstates?
Are there other types of highways (non-interstates) in the data?
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.