This document is archived and information here might be outdated.  Recommended version.


How to build a raster attribute table (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Managing data > Working with image and raster data > Accessing raster datasets > How to build a raster attribute table

How to build a raster attribute table


Building a raster attribute table

You can build a raster attribute table using the Build Raster Attribute Table Geoprocessing tool. By default, the raster attribute table contains 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. This topic shows how to achieve this task using ArcObjects.
Do the following steps to build a raster attribute table:
  1. Cast to IRasterDatasetEdit2 to build a raster attribute table.
  2. To build a default raster attribute table with VALUE and COUNT fields use the BuiltAttributeTable method on the IRasterDastsetEdit2 interface.
  3. To assign an existing table as a raster attribute table use the AlterAttributeTable method on the IRasterDatasetEdit2 interface.

    See the following code example:
[C#]
static void BuildRasterAttributeTable(IRasterDataset rasterDataset, ITable table)
{
    //Cast to IRasterDatasetEdit2 to build a raster attribute table.
    IRasterDatasetEdit2 rasterDatasetEdit=(IRasterDatasetEdit2)rasterDataset;

    //Build a 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);
    }
}
[VB.NET]
Public Sub BuildRasterAttributeTable(ByVal rasterDataset As IRasterDataset, ByVal table As ITable)
    'Cast to IRasterDatasetEdit2 to build a raster attribute table.
    Dim rasterDatasetEdit As IRasterDatasetEdit2=CType(rasterDataset, IRasterDatasetEdit2)
    
    'Build a default raster attribute table with VALUE and COUNT fields.
    If table Is Nothing Then
        rasterDatasetEdit.BuildAttributeTable()
    Else
        'Assign the given table as the raster attribute table.
        rasterDatasetEdit.AlterAttributeTable(table)
    End If
End Sub


See Also:

How to access a raster dataset




Development licensing Deployment licensing
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
Engine Developer Kit Engine