0

I need help with the syntax with my label expression. I have a specific set of parameters I need to display but I need to change only one attribute to label as something else.

I have AC pipeline that I need to label as NM. How do I get everything else to label but have anything that equals AC change to NM?

A quick work around for me was to duplicate the layer and do a Definition Query and do a simple label expression. My other layer excluded my AC mains and labeled them normally. I know there is a way to build a more complex syntax to complete this task without having to duplicate layers and create Definition queries. Here is the VBScript I have currently.

I am assuming is it would be an if then else statement...not sure how to actually write it correctly though.

enter image description here

  • If you are using ArcGIS 10.1 or later then using Python for labelling like this would be my preference. – PolyGeo Feb 23 '15 at 21:53
  • I am using 10.2.2 - I guess I should have included that. Even with that said PolyGeo...what would the syntax look like? That is where I am running into problems. I will admit though that I am not skilled in Python (yet!) – AReaGIS Feb 23 '15 at 22:06
  • 2
    I'd use 'Define classes of features and label each class differently' in Layer Property-Labels window. This is much more flexible tool, you might change fonts and color etc – FelixIP Feb 23 '15 at 22:23
1

What I think you really need is to use label classes. More info is available in the help documentation at http://resources.arcgis.com/en/help/main/10.2/index.html#//00s80000000v000000

Basically though, what you would be doing is creating different classes of labels that you can label differently, just like you can classify your symbology so different features draw differently within the same layer. The easiest way to work with label classes is if you already have them classified for symbology, to just go to the labels tab of layer properties and under method tell it to define classes of features and then use the button Get Symbol Classes. Otherwise, follow those same steps except don't click the get symbol classes button, but instead use the add button and the SQL Query buttons to add classes as necessary. Truth be told though, to work with labels easiest, I would recommend opening up the label toolbar and using the label manager (available from that toolbar).

If you use label classes, you can set it so features that meet your criteria ex:[FIELD] = "AC" are labeled differently than the rest of the features.

Additionally, I think if you change the label expression parser to Python, you should be able to simply use the .replace() method, depending on how your data is set up to replace the AC with NM. For example, the label expression might be something similar to str([Diameter]) + " " + str([Material]).replace('AC','NM') + " " + str([Date])

  • I understand where you are going with this John. I need some clarification. Let's say I call my label class AC to NM, then I would build a SQL Query to say [Material]= 'AC' correct? This is telling the class to find everything that is AC. Then in my Text String expression if where I would add addition formatting for the label like [Diameter] & " '' " & "NM"? Is this correct? – AReaGIS Feb 23 '15 at 23:19
  • 1
    I got it to work John! Label classes was the way to go. I learned something very cool today. Thank you guys! – AReaGIS Feb 23 '15 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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