Skip to main content
added 2 characters in body; edited tags; edited title
Source Link
PolyGeo
  • 65.5k
  • 29
  • 115
  • 353

How can you alter Altering label styles (font, color, size, etc.) using Python scriptingArcPy? (ArcGIS 10.2)

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.

My question here is, whatWhat expression or function would you use in arcpy to alter the style of these labels? Currently

Currently, the script labels the apartments by a map code and changes its name in the TOC to apartments, as it should.   

enter image description here

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

Is there any way the fonts, labels, and graphics can be changed with the use of Python scripting (ArcPy, IDLE, etc.)?

 

EDIT: 10/30/2014: II 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:   

enter image description here

 

EDIT: 10/31/2014 II have tried utilizingusing 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]) 

How can you alter label styles (font, color, size, etc.) using Python scripting? (ArcGIS 10.2)

I am trying to write a python macro 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.

My question here is, 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.  enter image description here

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.)?

EDIT: 10/30/2014: 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:  enter image description here

EDIT: 10/31/2014 I have tried utilizing 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]) 

Altering label styles (font, color, size, etc.) using ArcPy?

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. 

enter image description here

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: 

enter image description here

 

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]) 
added 1028 characters in body
Source Link
Tyler Spears
  • 135
  • 1
  • 2
  • 8

I am trying to write a python macro 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.

My question here is, 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. enter image description here

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.)?

EDIT: 10/30/2014: 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: enter image description here

EDIT: 10/31/2014 I have tried utilizing 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]) 

I am trying to write a python macro 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.

My question here is, 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. enter image description here

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.)?

EDIT: 10/30/2014: 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: enter image description here

I am trying to write a python macro 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.

My question here is, 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. enter image description here

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.)?

EDIT: 10/30/2014: 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: enter image description here

EDIT: 10/31/2014 I have tried utilizing 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]) 
added 300 characters in body
Source Link
Tyler Spears
  • 135
  • 1
  • 2
  • 8

I am trying to write a python macro 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.

My question here is, 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. enter image description here

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.)?

EDIT: 10/30/2014: 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: enter image description here

I am trying to write a python macro 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.

My question here is, 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. enter image description here

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 am trying to write a python macro 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.

My question here is, 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. enter image description here

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.)?

EDIT: 10/30/2014: 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: enter image description here

edited tags
Link
PolyGeo
  • 65.5k
  • 29
  • 115
  • 353
Loading
Source Link
Tyler Spears
  • 135
  • 1
  • 2
  • 8
Loading