Select to view content in your preferred language

arcpy.mp to reverse classes order sybmology graduated colors

784
2
12-05-2019 08:08 AM
TysonTaylor
Occasional Contributor

Does anyone have some sample code using arcpy.mp that will reverse the values for the classes order using a graduatedcolorrender?

What I am trying to do is automate this step using arc.mp. in ArcGIS pro the functionality or step is in the symbology window using graduated colors, natural breaks (method) in the classes tab there is a more pull down where you can reverse values.

thanks

Tyson

2 Replies
curtvprice
MVP Esteemed Contributor

This level of granularity/detail requires .NET programming, arcpy.mp is higher level - it doesn't have every bit of functionality like the pulldown you mention implemented as a method applicable to the layer object.

However, you can set up a symbology interactively, save to a lyrx file and use arcpy.mp to apply the .lyrx symbology to a layer.

JaredPilbeam2
MVP Regular Contributor

Just curious whether there were any updates to arcpy.mp that allow you to reverse the color ramp?

Funny thing is, I can set, for example, Yellow to Red but not Red to Yellow.

 

This works:

 

sym.renderer.colorRamp = p.listColorRamps('Yellow to Red')[0]

 

 

This produces an error:

 

sym.renderer.colorRamp = p.listColorRamps('Red to Yellow')[0]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
In  [40]:
Line 15:    sym.renderer.colorRamp = p.listColorRamps('Red to Yellow')[0]

IndexError: list index out of range
---------------------------------------------------------------------------

 

 

0 Kudos