It is through the Symbology class that you can gain access to a feature layer's renderer or a raster layer's colorizer.


The typical workflow is to reference a layer's symbology, make changes, and then apply those changes back to the layer.

It is important to first make sure that a layer supports a renderer or colorizer and to know its type before trying to make updates to it. The built in hasattr function can be used for this purpose.

The following feature layer renderers are currently supported in SimpleRenderer, GraduatedColorsRenderer, GraduatedSymbolsRenderer, and UniqueValueRenderer.

The following raster colorizers are supported: RasterClassifyColorizer and RasterUniqueValueColorizer.


プロパティ説明データ タイプ

Gets the colorizer object for a raster layer. The supported types are: RasterClassifyColorizer and RasterUniqueValueColorizer.


Gets the renderer object for a feature layer. The supported types are: GraduatedColorsRenderer, GraduatedSymbolsRenderer, SimpleRenderer, or UniqueValueRenderer.



updateColorizer (colorizer_name)

The updateColorizer method is used to change a raster layer's colorizer.

updateRenderer (renderer_name)

The updateRenderer method is used to change a layer's renderer.


updateColorizer (colorizer_name)
パラメーター説明データ タイプ

The supported renderers are as follows:

  • RasterClassifyColorizerA raster classify colorizer.
  • RasterUniqueValueColorizerA raster unique value colorizer.

You can only update from supported colorizer to supported colorizer. For example, you can update a raster classify colorizer to a raster unique value colorizer or vice versa, but you can't update to a raster stretch colorizer, because it is not currently supported.

updateRenderer (renderer_name)
パラメーター説明データ タイプ

The supported renderers are as follows:

  • GraduatedColorsRendererA graduated colors renderer
  • GraduatedSymbolsRendererA graduated symbols renderer
  • SimpleRendererA single symbol renderer
  • UniqueValueRendererA unique value renderer

The SimpleRenderer is the same as the single symbol renderer you see in the application. This name is used to be consistent with the .NET API.


Symbology example 1

The following script iterates through each feature layer and tests if its symbology supports the renderer property using the hasattr function. Next, if the renderer type is a SimpleRenderer, it will change it to a GraduatedColorsRenderer using the updateRenderer method and then sets its breakCount value to 6. Finally, it applies the symbology back to the layer before saving the results.

import arcpy, os, sys
relpath = os.path.dirname(sys.argv[0])

p = + r'\\Symbol.aprx')
m = p.listMaps('Map')[0]

for lyr in m.listLayers():
  if lyr.isFeatureLayer:
    sym = lyr.symbology
    if hasattr(sym, 'renderer'):
      if sym.renderer.type == 'SimpleRenderer':
        sym.renderer.breakCount = 6
        lyr.symbology = sym

p.saveACopy(relpath + r"\\SavedOutput.aprx")
Symbology example 2

The following script first tests if the layer's symbology supports a colorizer property and then confirms if the renderer is a RasterClassifyColorizer. Next is changes the classificationField and breakCount. Finally, it changes ColorRamp to a color ramp named Cyan to Purple.

import arcpy
import os
import sys

relpath = os.path.dirname(sys.argv[0])

p = + r'\\RasterClassify.aprx')
m = p.listMaps('Map')[0]
l = m.listLayers('Raster1')[0]
sym = l.symbology

if hasattr(sym, 'colorizer'):
    if sym.colorizer.type == 'RasterClassifyColorizer':
        sym.colorizer.classificationField = 'Value'
        sym.colorizer.breakCount = 7
        sym.colorizer.colorRamp = p.listColorRamps('Cyan to Purple')[0]
        l.symbology = sym

p.saveACopy(relpath + r'\\SavedOutput.aprx')