How to access a raster attribute table for an image service


Summary
At ArcGIS 10.1, image service supports raster attribute tables on categorical data source. This topic covers how to access raster attribute tables for an image service.

Accessing a raster attribute table for an image service

The following code example shows how to access the attribute table of an image service that serves thematic imagery:
[C#]
public static IRecordSet GetRasterAttributeTable(IImageServer imageServer)
{
    //Get raster attribute table.
    IImageServiceInfo3 isInfo = imageServer.ServiceInfo as IImageServiceInfo3;
    if (isInfo.HasRasterAttributeTable)
        return ((IImageServer4)imageServer).RasterAttributeTable;
    else
        return null;
}
[VB.NET]
Public Shared Function GetRasterAttributeTable(ByVal imageServer As IImageServer) As IRecordSet
'Get raster attribute table.
Dim isInfo As IImageServiceInfo3 = TryCast(imageServer.ServiceInfo, IImageServiceInfo3)
If isInfo.HasRasterAttributeTable Then
    Dim recordSet As IRecordSet = DirectCast(imageServer, IImageServer4).RasterAttributeTable
    Return recordSet
Else
    Return Nothing
End If
End Function






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
Engine Developer Kit Engine