I have a raster layer with 3 unique values (1,2,3) and I want to apply a unique color to each using RGB values or hex codes, without the use of a symbology layer (layer file).
Is it possible to create a color map or symbology layer (layer file) entirely in ArcPy?
I want my code to add the raster layer to the map with the symbology I want (as opposed to random), but I don't want to use a pre-created symbology layer (layer file) or colormap - I would like the colors to be selected entirely in ArcPy, if possible.
arcpy.MakeRasterLayer_management(cat, "cat")
arcpy.SaveToLayerFile_management("cat", "cat.lyr", "ABSOLUTE")
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "*")[0]
arcpy.mapping.AddLayer(df, "cat.lyr", "TOP")
# this is where I want to apply unique colors to each pixel value (pixel values are: 1,2,3)
# but I don't want to use add colormap or apply symbology from layer, unless the symbology
# layer or colormap can be created entirely in arcpy. I would like the color decisions
# to be made entirely in arcpy, without having to make a symbology layer or colormap
# in the GUI
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
del mxd, df
something like this?
colormap = open("colormap.clr", "w")
colormap.write("1 70 137 102\n")
colormap.write("2 255 176 59\n")
colormap.close()