I have a custom overlay grid whose labels are driven by an ugly attribute field which contains unnecessary leading zeroes and other labeling no-nos.
How can I introduce a labeling expression to this grid?
I am using ArcGIS 10 SP1 for Desktop.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
You can use many expressions in the label expression dialog.
You might try using regex to get at some of the hard to reach problems.
Here is one of my old questions that can show how it can be used.
If it is just trailing or leading zeros you can use...
that will drop everything in the front leaving only 4 characters from the right side.
Function FindLabel( [NAME] ) Dim fldValue, aWords, i, word, aNewWords, NewWord, numElements, k fldValue = [NAME] 'k = 0 'One word first line and two words all other lines k = 1 'Two words first line and all other lines if not IsNull(fldValue) then aWords = split(fldValue, " ") numElements = UBound(aWords) 'Create new array to store new field value and redimmension to store ' the correct number of elements to match original number of elements aNewWords = Array() Redim aNewWords(numElements) for i = LBound(aWords) to UBound(aWords) if i Mod 2 = k then word = aWords(i) & vbCr else word = aWords(i) end if aNewWords(i) = word next NewWord = Join(aNewWords, " ") else NewWord = fldValue end if FindLabel = NewWord End Function
This is an example of a label expression from streetmap.
Label expressions for a feature layer may be set by going to the the layers Properties>Labels tab, and click on the Expression button. However, Jakub has a good point that you should clean up your data first via field calculator. Here is the ArcGIS 10 link for feature expressions.