1

I have a Jupyter Notebook in my ArcGIS Pro project which changes the symbology of my map layer. In this script I manually set the class breaks using the classBreakValues variable which works as long as the list starts from the lowest number (3) to the highest (15). Example below:

from datetime import datetime # for obtaining today's date
import os

# set up project and map
p = arcpy.mp.ArcGISProject('CURRENT')
m = p.listMaps('Map')[0]
lyr = m.listLayers('PHUC4s_joinedData')[0]
Layout = p.listLayouts('Layout')[0]

# create a list of fields
fields = arcpy.ListFields(lyr) # creates a list of fields

# create the outputs
sym.updateRenderer('SimpleRenderer') # reset renderer
sym.updateRenderer('GraduatedColorsRenderer')
sym.renderer.classificationField = 'complete_data.csv.Ind_RegRank_pctRank'
sym.renderer.breakCount = 4
sym.renderer.colorRamp = p.listColorRamps('Oranges (Continuous)')[0]

## general change for most legends
classBreakValues = [3, 7, 10, 15]
classBreakLabels = ['3', '7', '10', '15']
label_loop_count = 0                            
for brk in sym.renderer.classBreaks:
    brk.upperBound = classBreakValues[label_loop_count]
    brk.label = classBreakLabels[label_loop_count]
    label_loop_count += 1 

# save symbology back into the layer
lyr.symbology = sym

Now the issue is that I want to reverse the color scheme so that the lowest numbers are the darkest. I tried to change classBreakValues to [15, 10, 7, 3] to reverse the color order but the outcome is just a single-colored map set to whatever color is set to 15.

Example output of the code I posted above.

This map is an example output from the code I posted above. Here I have classBreakValues = [3, 7, 10, 15]. If I try to reverse the colors with classBreakValues = [15, 10, 7, 3] I end up with a map only filled with that white color. My ultimate goal is to just reverse the color order.

1 Answer 1

0

There doesn't seem to be a one-liner to reverse the color scheme, but I was able to do so by looking at the RGB values for a color scheme in ArcGIS Pro and manually plugging them in for "brk.symbol.color".

#imports
from datetime import datetime # for obtaining today's date
import os

# set up project and map
p = arcpy.mp.ArcGISProject('CURRENT')
m = p.listMaps('Map')[0]
lyr = m.listLayers('PHUC4s_joinedData')[0]
Layout = p.listLayouts('Layout')[0]

# create a list of fields
fields = arcpy.ListFields(lyr) # creates a list of fields

# create the outputs
sym = lyr.symbology
sym.updateRenderer('SimpleRenderer') # reset renderer
sym.updateRenderer('GraduatedColorsRenderer')
sym.renderer.classificationField = 'complete_data.csv.Ind_RegRank_pctRank'
sym.renderer.breakCount = 4


## general change for most legends
classBreakValues = [3, 7, 10, 15]
classBreakLabels = ['3', '7', '10', '15']
classBreakColorOrange = [{'RGB' : [127, 39, 4, 100]},
                         {'RGB' : [233, 94, 13, 100]},
                         {'RGB' : [253, 185, 125, 100]},
                         {'RGB' : [255, 245, 235, 100]}                         
                        ]

label_loop_count = 0                            
for brk in sym.renderer.classBreaks:
    brk.upperBound = classBreakValues[label_loop_count]
    brk.label = classBreakLabels[label_loop_count]
    brk.symbol.color = classBreakColorOrange[label_loop_count]
    label_loop_count += 1 

# save symbology back into the layer
lyr.symbology = sym

This created a map where the low numbers are dark and high numbers are lighter...shown below: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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