How to add or remove a color map from a raster dataset


Adding or removing a color map from a raster dataset

This article demonstrates the steps to add or remove a color map from a raster dataset. The raster dataset has to be a single-band dataset to apply a color map. See the following code example:
[Java]
static void addRemoveColormap(IRasterDataset rasterDataset, IRasterDataset
    colormapDataset)throws Exception{
    //If the colormapDataset is null, it will remove the colormap.
    //If the colormapDataset is not null, it will add the colormap of the colormapDataset to the input raster.

    //Cast to IRasterDatasetEdit for the colormap operation.
    IRasterDatasetEdit rasterDatasetEdit = new IRasterDatasetEditProxy(rasterDataset)
        ;

    //Add a colormap from a given raster dataset.
    if (colormapDataset != null){
        //Get raster colormap from the given raster dataset.
        IRasterBandCollection rasterBandCollection = new IRasterBandCollectionProxy
            (colormapDataset);
        IRasterBand rasterBand = rasterBandCollection.item(0);
        IRasterColormap rasterColormap = rasterBand.getColormap();
        if (rasterColormap != null){
            rasterDatasetEdit.alterColormap(rasterColormap);
        }
    }
    else{
        //Remove the raster colormap.
        rasterDatasetEdit.deleteColormap();
    }
}


See Also:

How to access a raster dataset or raster catalog




Development licensingDeployment licensing
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine