How to alter a raster colormap


This sample shows how to alter a raster colormap for a given raster dataset with a given raster dataset with colormap. The raster dataset can be file-based raster dataset or geodatabase raster dataset.

How to use

  1. Call this procedure from VBA.
[VBA]
Sub alter_colormap(pRasterDs As IRasterDataset, pColormapDs As IRasterDataset2)
    
    ' Alter raster colormap for the input raster dataset with the colormap of given dataset
    
    Dim pRasterDatasetEdit As IRasterDatasetEdit2
    ' QI for IRasterRasterDatasetEdit2
    Set pRasterDatasetEdit = pRasterDs
    ' Alter colormap
    Dim pRaster As IRaster2
    Set pRaster = pColormapDs.CreateDefaultRaster
    
    pRasterDatasetEdit.AlterColormap pRaster.Colormap
    ' Cleanup
    Set pRasterDatasetEdit = Nothing
    Set pRaster = Nothing
    
End Sub