Add Colormap (Data Management)
Summary
Adds a color map to a raster dataset if it does not already exist or replaces a color map with the one specified.
Usage
-
The color map applied to the input raster dataset can originate from a raster dataset that already has a color map, a .CLR file, or an .ACT file.
-
This tool will not work when the color map is internally stored in the attribute table of an IMG or TIFF dataset. If the attribute table contains the fields Red, Green, and Blue, that means this tool cannot be used.
-
The input raster dataset must be a single band raster dataset with integer values. Color maps can only be created for single-band raster datasets with a pixel depth of 16-bit unsigned or fewer. Certain formats cannot have a color map associated with them; please consult the Supported raster dataset file formats.
Syntax
Parameter | Explanation | Data Type |
in_raster |
The input raster dataset to which you want to add a color map. | Raster Layer |
in_template_raster (Optional) |
The raster dataset with a color map, that will be applied to the input raster dataset. If this is entered the input_CLR_file cannot be specified. | Raster Layer |
input_CLR_file (Optional) |
The .clr or .act file, which will be used as the template color map for the input raster dataset. If this is entered the in_template_raster cannot be specified. | File |
Code Sample
This is a Python sample for AddColormap.
import arcpy
arcpy.AddColormap_management("c:/data/nocolormap.img", "#",
"colormap_file.clr")
This is a Python script sample for AddColormap.
##====================================
##Add Colormap
##Usage: AddColormap_management in_raster {in_template_raster} {input_CLR_file}
try:
import arcpy
arcpy.env.workspace = r"C:/Workspace"
##Assign colormap using template image
arcpy.AddColormap_management("nocolormap.img", "colormap.tif", "#")
##Assign colormap using clr file
arcpy.AddColormap_management("nocolormap.img", "#", "colormap_file.clr")
except:
print "Add Colormap example failed."
print arcpy.GetMessages()