3

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.

4
  • is your overlay grid in a raster or vector format?
    – artwork21
    May 12, 2011 at 17:22
  • @artwork21: the overlay grid is driven by a feature class comprised of vector polygon geometry.
    – MLF
    May 12, 2011 at 17:41
  • 2
    Can't you create another column and clean up the values with vb script in the calculator? May 12, 2011 at 17:55
  • 1
    Not to be snarky, but have you read the manual? May 12, 2011 at 20:42

3 Answers 3

2

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...
Right ([mycolumn],4)

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.

1

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.

4
  • 1
    We are a large organization, and use SDE with strict permissions. I am not able to add a field unless I divorce the data from the SDE, and at that point, the end user would not benefit from modifications to the data (and indeed, we are about to update it), so that won't help here.
    – MLF
    May 12, 2011 at 20:08
  • I'm not trying to modify labels on a feature layer. The custom overlay grid is a different beast all its own and does not have the same labeling options as the feature class itself. I want to inject some label class scripting into the actual grid.
    – MLF
    May 12, 2011 at 20:11
  • What do you mean by "a different beast"? Isn't this a polygon feature class with attributes? it would be best to actually clean up the source data with vbscript or python, whichever you prefer. You can of course do it with label expressions but it has certain disadvantages such as slower drawing times... Kirk has provided a link to the manual. May 13, 2011 at 12:52
  • @ Jakub: This is a custom overlay grid. The only options to label a custom overlay grid are to label it according to one field inside the feature class, and there is no option to use a label expression.
    – MLF
    May 17, 2011 at 16:31
1

Per Esri, it is not possible at this time to incorporate a label expression with a custom overlay grid; Label expressions are not supported with grid labels.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.