How to build a raster attibute table


This sample shows how to build a raster attribute table for a given raster dataset. The raster dataset can be file-based raster dataset or geodatabase raster dataset.

How to use

  1. Call this procedure from VBA.
[VBA]
Sub build_atrributetable(pRasterDs As IRasterDataset)
    
    ' build the default raster attribute table for the input raster dataset
    ' the default raster attribute table has two fields: value and count
    Dim pRasterDatasetEdit As IRasterDatasetEdit2
    ' QI for IRasterRasterDatasetEdit2
    Set pRasterDatasetEdit = pRasterDs
    ' Build default attribute table
    pRasterDatasetEdit.BuildAttributeTable
    ' Cleanup
    Set pRasterDatasetEdit = Nothing
    
End Sub