Reverse Symbology Colorramp using ArcPy

648
0
09-12-2020 03:57 AM
DavidKerr
New Contributor

Hi

I'm trying to automate the styling/publishing of around 1000 layers. I would like to use Viridis colorramp, but with the yellows as low values, and purple as high, but the default only offers the opposite and no function to reverse the order. Is there any way to do this as you can do in the Symbology GUI in ArcPro?

This is the function that I'm currently using:

def style_layer(selfshpaprxbreaks😞
        """Manually style layer using array of breaks
         shp --> path to shapefile
         aprx --> Project file
         breaks --> list of breaks to use in the manual styling method
         """
        year = shp.parent.name
        p = arcpy.mp.ArcGISProject(str(aprx))
        m = p.listMaps()[0]
        l = m.listLayers()[0]
        sym = l.symbology
        if sym.renderer.type == 'SimpleRenderer':
            sym.updateRenderer('GraduatedColorsRenderer')
        sym.renderer.classificationField = shp.stem
        sym.renderer.colorRamp = p.listColorRamps('Viridis')[0]  <-------THIS IS WHAT I WOULD LIKE TO REVERSE
        p.save()
        sym.renderer.breakCount = len(breaks)
        classBreakLabels = [round((x * 100), 2for x in breaks]
        for index, brk in enumerate(sym.renderer.classBreaks):
            brk.upperBound = breaks[index]
            brk.label = classBreakLabels[index]
        l.symbology = sym
        p.save()
0 Kudos
0 Replies