How to alter a raster attribute table


This sample shows how to alter a raster attribute table for a given raster dataset with a given table. 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_attributetable(pRasterDs As IRasterDataset, pTable As ITable)
    
    ' Alter raster attribute table for the input raster dataset with the input table
    
    Dim pRasterDatasetEdit As IRasterDatasetEdit2
    ' QI for IRasterRasterDatasetEdit2
    Set pRasterDatasetEdit = pRasterDs
    ' Alter attribute table
    If pRasterDatasetEdit.CanAlterAttributeTable Then
        pRasterDatasetEdit.AlterAttributeTable pTable
    End If
    ' Cleanup
    Set pRasterDatasetEdit = Nothing
    
End Sub