AnsweredAssumed Answered

Reverse Symbology Colorramp using ArcPy

Question asked by Kerr_WorldPop on Sep 12, 2020


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 =
        p =
        m = p.listMaps()[0]
        l = m.listLayers()[0]
        sym = l.symbology
        if sym.renderer.type == 'SimpleRenderer':
        sym.renderer.classificationField = shp.stem
        sym.renderer.colorRamp = p.listColorRamps('Viridis')[0]  <-------THIS IS WHAT I WOULD LIKE TO REVERSE
        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