I want to make sure that any maps I make in ESRI’s ArcMap look as good as possible, and one thing I believe looks good on a map is street names having proper case. That is, instead of the name being completely uppercase or lowercase, the first letter of each word is capitalized while the rest of the letters in the word are lowercase.
The problem I have run into with the county’s data is that everything in the system seems to be capitalized, whether is be street names, the owner’s name to a parcel, or whatever. Everything is all uppercase. This is fine for within the database, actually I have issues with it, but I do not want to get into that in this blog post. So, what am I to do? After several iterations, I have hammered out what I think is a pretty good VBScript solution which will take the uppercase data passed to it and return a proper case result. In the following example, I am getting as parameters the street name (i.e. MAIN) and the street type (i.e. ST), but this could be altered to first and last name, or only a single parameter; you get the idea. This script takes care of names with spaces and apostrophes too.
Function FindLabel([ST_NAME], [ST_TYPE]) Dim label, labelWords, i, j, retVal, word, apostWords label = [ST_NAME] & “ “ & [ST_TYPE] If (NOT IsNull(label) AND Len(label) > 0) Then labelWords = Split(label) For i = 0 To UBound(labelWords) If (i > 0) Then retVal = retVal & " " End If word = UCase(Left(labelWords(i), 1)) & LCase(Mid(labelWords(i), 2)) apostWords = Split(word, "'") word = "" For j = 0 To UBound(apostWords) If j > 0 Then word = word & "'" End If word = word & UCase(Left(apostWords(j), 1)) & LCase(Mid(apostWords(j), 2)) Next retVal = retVal & word Next Else retVal = "" End If FindLabel = retVal End Function
Feel free to use this within your ArcMap’s Label Expressions and I hope it helps someone else out in the future.
AUTHOR NOTE: I had originally written this function in JScript, but for some unexplainable reason, ArcMap simply did not like my code, so I switched to /sigh/ VBScript instead.