This sample shows how to get a value in a raster table given a field and an index.
How to use
- Call this procedure from VBA.
Sub AccessValueOfRasterTable(pRaster As IRaster, sFieldName As String, RowIndex As Integer)
' pRaster: input raster
' sFieldName: field name in the raster table
' RowIndex: row index in the table
' Get Rasterband
Dim pRasterCol As IRasterBandCollection
Set pRasterCol = pRaster
Dim pBand As IRasterBand
Set pBand = pRasterCol.Item(0)
' Get the raster table
Dim pTable As ITable
Dim TableExist As Boolean
pBand.HasTable TableExist
If Not TableExist Then Exit Sub
Set pTable = pBand.AttributeTable
' Get field index
Dim FieldIndex As Integer
FieldIndex = pTable.FindField(sFieldName)
' Get the value
Dim ValueResult As Variant
Dim pRow As IRow
Set pRow = pTable.GetRow(RowIndex)
ValueResult = pRow.Value(FieldIndex)
' Here is the result
MsgBox ValueResult
End Sub