0

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 Oct 17 '13 at 20:20
2

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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