Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a field in a shapefile with values ranging from 1-50 and multiple listed as 0. Is there a way to label only the features where the number in the priority field is > 0?

share|improve this question

3 Answers 3

up vote 5 down vote accepted

You can put this as the label expression for the feature:

def FindLabel([yourField]):
    if [yourField] is not None:
        if int([yourField]) > 0:
            return [yourField]
        else:
            return None
    else:
        return None

Using Python as the parser and checking the Advanced box.

Replace [yourField] with whatever field you are using to label.

share|improve this answer
    
note, in python it's better to say if XXXX is not None: –  Paul H Mar 26 at 16:54
1  
Thanks Paul, that's actually what I normally use. I'll update my answer accordingly. –  ian Mar 26 at 17:34

I deal with this from time to time. You should use the Expression button in the Label tab. There you use the Advanced parser (checkbox), and write something like this (Python):

def FindLabel ( [Name], [V5] ):
 if [V5] == "0":
   return "<BOL>"+ [Name]+"</BOL>"
 else:
  return "<BOL>"+ [Name]+"</BOL>" + "\n" +"<FNT size = '6'>"+  str([V5] )+"</FNT>"

This will return labels for each feature from field Name in bold, and in smaller print the value from V5for those that are > 0 (assuming non-negative values).

share|improve this answer

In Layer Properties - Labels- Method click the drop down to select Define Classes, then use the SQL Query to limit the label to only those features.

Alternately you could use a selection query for those features, save the selection as a new layer in your TOC using the create features option, and then label those features.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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