How to change the renderer for raster catalogs


This sample shows how to modify raster renderer for the geodatabase raster catalogs.

How to use

  1. Add a 9.x version raster catalog that contains three band images into ArcMap and make sure the it is the first layer in TOC
  2. Run the procedure.
[VBA]
Sub ModifyRasterCatalogRenderer()
    'Get the document
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    
    'Get raster catalog layer
    Dim pLayer As ILayer
    Dim pRasCatalogLy As IGdbRasterCatalogLayer
    Set pLayer = pMxDoc.FocusMap.Layer(0)
    If Not TypeOf pLayer Is IGdbRasterCatalogLayer Then
        MsgBox "First layer is not 9.x version raster catalog"
    End If
    Set pRasCatalogLy = pLayer
    
    'Get the renderer array
    Dim pRenderArr As IArray
    Set pRenderArr = New esriSystem.Array
    Set pRenderArr = pRasCatalogLy.Renderers
    
    'Find the RGB renderer
    Dim i As Integer
    Dim pRGBRender As IRasterRGBRenderer
    For i = 0 To pRenderArr.Count - 1
        If TypeOf pRenderArr.Element(i) Is IRasterRGBRenderer Then
            Set pRGBRender = pRenderArr.Element(i)
        End If
    Next
    
    'Customize the RGB renderer
    pRGBRender.SetBandIndices 2, 1, 0
    
    'Add to ArcMap
    pMxDoc.FocusMap.AddLayer pRasCatalogLy
    pMxDoc.ActiveView.Refresh
    
End Sub