I want to set the symbology across multiple rasters to use custom min/max values. The following script is working as intended, and the raster displays correctly. However, the Symbology window does not update to show the correct min/max values and 'Custom' statistics until the project is closed and reopened. Is there a way to force a refresh of the symbology window?

These three screenshots show the symbology window (1) before running the tool, (2) after running the tool, and (3) after closing and reopening the project.

symbology window updates

import arcpy
#get current project and map view
p = arcpy.mp.ArcGISProject('CURRENT')
m = p.activeMap

#get raster layer
lyr  = m.listLayers('RasterLayerName')[0]

#define min/max for display
minVal = 60
maxVal = 130

#set symbology (color ramp, labels, stretch type)
sym = lyr.symbology
sym.colorizer.stretchType = 'MinimumMaximum'
cr = p.listColorRamps('Elevation #1')[0]
sym.colorizer.colorRamp = cr
sym.colorizer.minLabel = "Min: " + str(minVal)
sym.colorizer.maxLabel = "Max: " + str(maxVal)
lyr.symbology = sym

#use CIM to set custom statistics
cim_lyr = lyr.getDefinition('V2')
cim_lyr.colorizer.statsType = 'GlobalStats'
cim_lyr.colorizer.useCustomStretchMinMax = True
cim_lyr.colorizer.stretchStats.max = maxVal
cim_lyr.colorizer.stretchStats.min = minVal

1 Answer 1


Your code works without any issue except you have a typo in the second line below:

sym.colorizer.minLabel = "Min: " + str(minVal)
sym.colorizer.maxLabel = "Max: " + str(minVal) # ←

It should be:

sym.colorizer.maxLabel = "Max: " + str(maxVal)

and it refreshes the symbology instantly.

enter image description here

  • Good catch, I fixed the typo. The symbology does update, but the Symbology window does not, as shown in the screenshots. The concern is that what displays on the map isn't accurately reflected in the Symbology Window and can't be confirmed or edited until restarting ArcGIS Pro.
    – Brennan
    Commented Mar 22, 2022 at 12:09
  • I think it is something related to the rendering setting in your ArcGIS Pro, it is not related to the python code itself. Please check the settings under ArcGIS Pro → Project → Options, and check the Display settings.
    – ahmadhanb
    Commented Mar 23, 2022 at 0:46

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.