How to build a raster attribute table


Summary
This article shows how to build a raster attribute table for a single-band integer raster dataset.

Building a raster attribute table

By default, the raster attribute table will contain VALUE and COUNT fields. If a table is assigned to the raster dataset as its raster attribute table, it will be attached to the raster dataset and be part of the dataset. See the following code example:
[Java]
static void buildRasterAttributeTable(IRasterDataset rasterDataset, ITable table)
    throws Exception{
    //Cast to IRasterDatasetEdit2 for building a raster attribute table.
    IRasterDatasetEdit2 rasterDatasetEdit = new IRasterDatasetEdit2Proxy
        (rasterDataset);

    //Build default raster attribute table with VALUE and COUNT fields.
    if (table == null){
        rasterDatasetEdit.buildAttributeTable();
    }
    else{
        //Assign the given table as the raster attribute table.
        rasterDatasetEdit.alterAttributeTable(table);
    }
}






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