I have a series of (many) layers in an ArcGIS 10.1 map that are all symbolized using graduated colors. Each layer has the same number of breaks; however, the break values are different for each layer.
For the map legend, I have to prefix the labels for each of the layers so that it looks something like this:
0 - 50%: (break values)
50 - 75%: (break values)
75 - 90%: (break values)
etc...
I'm trying to find a programmatic way of inserting the prefixes into the labels. I know that arcpy gives read/write access to the labels via the classBreakLabels property.
I'm a Python newbie (but learning) so I'm wondering if it's even possible to read the current labels, load them into a list (or an array?), then add the prefix values (which are static and don't change).
Any suggestions?
-
Would you be able to include pictures of your Symbology tab and how you want your corresponding legend to look? Also, is there a Python snippet of what you are trying that you can include too?PolyGeo– PolyGeo ♦2013年10月17日 20:20:37 +00:00Commented Oct 17, 2013 at 20:20
1 Answer 1
I think I have it figured out - it was much simpler than I imagined. Not pretty, but here's the relevant code to update legend labels:
x = lyr.symbology.classBreakLabels
a = "0 - 50%: " + x[0]
b = "50 - 75%: " + x[1]
c = "75 - 90%: " + x[2]
d = "90 - 95%: " + x[3]
e = "95 - 98%: " + x[4]
f = "98 - 100%: " + x[5]
lyr.symbology.classBreakLabels = [a,b,c,d,e,f]
The output looks something like this in the legend:
0 - 50%: 0 - 10
50 - 75%: 11 - 20
75 - 90%: 21 - 30
etc...
It exports to PDF correctly, which is exactly what I need!