Change Raster Symbology to Colormap via ArcPy

226
1
04-18-2024 01:44 PM
Alec
by
New Contributor III

Hello! I have an arcpy script that essentially creates a stylized map from an input raster. In the script I apply a custom colormap to the raster. When the tool finishes, I have to go into the raster symbology and change the primary symbology from Unique Values  to  Colormap. When I do that my custom colormap populates the raster, but I can't figure out how to automate that step

This is the section of the code where I add the colormap

l = m.listLayers('Hillshade_Layer')[0]
l_cim = l.getDefinition('V3')
colormap_layer = m.listLayers("Elevation_Raster")[0]
arcpy.management.AddColormap(colormap_layer,"#", r"path\Blue_ColorMap.clr")



This is an example of how I have changed Raster symbology in the past with arcpy

sym = raster.symbology
sym.colorizer.type == "RasterStretchColorizer'"
sym.colorizer.colorRamp = p.listColorRamps('Color Ramp')[0]
raster.symbology = sym



If anyone has any answers or can point me towards any materials I would greatly appreciate it, I fee like I have read every ESRI page that there is 😂

Thank you ! 

Tags (3)
0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor
0 Kudos