Well I’ve been wanting to label certain features based on certain attributes (I  know exciting stuff), ArcGIS allows you to do this and until release 10 you were scripting this in VBScript.   Of course everyone is going Python now so I’m starting to use it…  The following is really a note for me to come back to, but it may help or interest others….

Right-click your layer you want to label, in the Layer Properties dialog box select the Labels Tab check Label features in this layer and click on the ” Expression Button”.   In the Label Expression dialog box select Python as the Parser and check the Advanced box.

Use this code:

 

def FindLabel ( [DistrictName], [QuarterCentre] ):
	if [QuarterCentre]:
		return  "<BOL><UND>"  + [DistrictName] + "</UND></BOL>"
	else:
		return [DistrictName]

Ensure you’ve tabbed everything as well, make sure you declare all the fields you want to use at the top. This basically checks the QauarterCentre field and if it has a value Bolds and Underlines the label.  Otherwise it just labels the feature.   To do the opposite you can use “if not [QuarterCentre]”.

For more information goto the ArcGIS 10.1 help here.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.