2

I created a shapefile for contours lines on the basis of a raster. Since I am interested in just 5 contours (out of, say, 50), I selected for display just the contours I am interested in. I achieved this from: properties > symbology > categories > unique values (from the 'contour' shapefile menu).

As expected, ArcMap is showing only the selected contours, BUT the labels of all the contours are actually showing up. I did not manage so far to fix this issue.

3

The Symbology tab of the Layer Properties does not perform any selections.

If you want the same features to not be labelled, I recommend that you apply a Definition Query instead:

When you specify a dataset that you want to draw as a map layer, you often only want to draw some of the features in the dataset. In these situations, you can define a query expression to select a subset of features for the layer display. This is referred to as a definition query.

3

You need to set a definition query (see link in @PolyGeo's answer) to show only the selected features that you wanted labeled. This can be done through the definition query tab in properties or through the labelling options called label classes (note - see @ChrisW comments below). I use these solution quite regularly and find them easy to do.

  • 2
    Label classes are separate from def queries. So it's possible to use a def query to limit the features shown, and then use a label class to only label some of the shown features. The def query method PolyGeo mentions is the shortest/simplest solution if only showing particular contours and labeling all of them. Your label class method is next in line and adaptable to showing all contours but only labeling some of them - two classes, one default that is not labeled and one that is labeled based on an SQL expression like "elevationfield" IN ('45', '50', '55', '60') – Chris W Jul 22 '15 at 20:43
  • @ChrisW, Totally agree. I think I am so use to using these methods that I have got into the bad habit of classing them under the same name. – TsvGis Jul 22 '15 at 21:46
  • @PolyGeo, how did you add the hyperlink to your answer, or rather where did you get the address from? – TsvGis Jul 22 '15 at 22:04
  • 2
    Under my answer you should see a share button that you can click to copy its URL. My user id is 115 and it is only the answer id that matters so I usually trim off the "/115" after pasting. – PolyGeo Jul 22 '15 at 22:43
1

You need to write an expression in the label tool, to make only your desired values visible.

Double-click the layer properties and select the label tab.

Locate the "Expression" button and select it.

Now you have to write the expression that will visualize only the desired values. You can choose between VBScript, Python, Jscript.

You will need to check "Advanced"; if VBScript is selected then you will see:

Function FindLabel ( [nome] )
FindLabel = [nome]
End Function

Your code will be something like this:

Function FindLabel ( [your_field] )
if ([your_field] = 10 ) then 
FindLabel = [your_field]
else if ([your_field] = 20 ) then
FindLabel = [your_field]
else 
FindLabel = ""
end if
end if
End Function

The instruction writes labels only if the field value is equal to the value inserted in the code; for all other values nothing will be displayed ("" -> this stands for no text). You will need to insert 5 "if statements" and 5 "end if"

  • The faster solution to this, rather than using a bunch of if statements, would be either a single CASE statement or a list. – Chris W Jul 22 '15 at 20:39
  • @ChrisW , yes you're right but I had this code ready to use so I just copy/pasted it here. – Vale Jul 23 '15 at 7:39

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.