I am trying to write a python macro for ArcGIS 10.2 that will automate the process of labeling points in a layer based on different types of apartments. For example, one style of apartments would have a blue square with white bold text as one label; another would have a pink square with black bold text; another would have a red square with a white bold text, etc.
What expression or function would you use in arcpy to alter the style of these labels?
Currently, the script labels the apartments by a map code and changes its name in the TOC to apartments, as it should.
Now I want to change the font, graphic, and size of the labels to look make a unique label for each, and then make a button to press and simply automate the process any time we have to do one of these layers.
Is there any way the fonts, labels, and graphics can be changed with the use of Python scripting (ArcPy, IDLE, etc.)?
I decided to edit this post to give a final description of what I'm going for here so there's no confusion. Essentially, the points on the map will go from looking like the above picture to this:
I have tried using the lblClass.expression
function, however the code I am trying to use doesn't work. I figure that is probably the step in the right direction. Below is some code that I've tried to use just to get the labelClass.expression to change the fonts of the labels.
for lblClass in aptLayer.labelClasses:
lblClass.showClassLabels = True
def getLabel (Code, Type):
if Type == "MRR":
return "<FNT name = 'Arial' size = '12'>" & Code & "</FNT>"
elif Type == "TAX":
return "<FNT name = 'Arial' size = '12'>" & Code & "</FNT>"
elif Type == "MRT":
return "<FNT name = 'Arial' size = '12'>" & Code & "</FNT>"
elif Type == "GSS":
return "<FNT name = 'Arial' size = '12'>" & Code & "</FNT>"
elif Type == "TGS":
return "<FNT name = 'Arial' size = '12'>" & Code & "</FNT>"
else:
return "<FNT name = 'Arial' size = '12'>" & Code & "</FNT>"
lblClass.expression = getLabel( [Map_Code],[Type])