How to convert 8.x referenced raster catalogs to 9.0 GDB raster catalogs


This sample shows how to Convert 8.x Referenced Raster Catalog to GDB Raster Catalog.

How to use

  1. Call this function from VBA.
[VBA]
Public Sub ConvertRasterCatalogToGDB(pCatTable As ITable, pCatalog As IRasterCatalog)
    
    ' This procedure converts 8.x raster catalog to 9.0 raster catalog
    ' Both the input and output raster catalogs have to exist
    ' Only raster field is converted, other fields are ignored
    
    ' ++++ convert an 8.x raster catalog to a 9.0 raster catalog
    
    Dim pFeat As IFeatureClass
    Dim pCatalogFeature As IRasterCatalogItem
    Dim pCursor As IFeatureCursor
    Dim pRow As IFeatureBuffer
    On Error GoTo er
    
    ' get 8.x raster catalog table
    
    Dim pCatalogTable As IRasterCatalogTable
    Set pCatalogTable = New RasterCatalogTable
    Set pCatalogTable = CreateObject("esriDataSourcesRaster.RasterCatalogTableSDE")
    Set pCatalogTable.Table = pCatTable
    pCatalogTable.Update
    
    ' create insert cursor
    
    Set pFeat = pCatalog
    Set pCursor = pFeat.Insert(False)
    
    ' load rasters in the 8.x raster catalog table to the new rastercatalog
    
    Dim i As Long
    For i = 0 To pCatalogTable.Size - 1
        Set pRow = pFeat.CreateFeatureBuffer
        pRow.Value(pCatalog.RasterFieldIndex) = createRasterValue(pCatalogTable.RasterDataset(pCatalogTable.OID(i)))
        pCursor.InsertFeature pRow
    Next i
    
    ' cleanup
    
    Set pCatalogFeature = Nothing
    Set pCursor = Nothing
    Set pRow = Nothing
    Set pCatalogTable = Nothing
    
    Exit Sub
er:
    MsgBox Err.Description, , "Conversion"
End Sub

Public Function createRasterValue(pRasterDs As IRasterDataset) As IRasterValue
    Dim pRasterVal As IRasterValue
    Dim pRasStoreDef As IRasterStorageDef
    On Error GoTo er
    
    ' ++ set storage parameter
    
    Set pRasStoreDef = New RasterStorageDef
    
    ' ++ set storage parameter
    
    Set pRasStoreDef = New RasterStorageDef
    
    ' ++ you can set the storage parameters here
    ' pRasStoreDef.CompressionType = esriRasterSdeCompressionTypeRunLength
    ' pRasStoreDef.PyramidLevel = 2
    ' ...
    
    ' ++ set raster value to raster field
    
    Set pRasterVal = New RasterValue
    Set pRasterVal.RasterDataset = pRasterDs
    Set pRasterVal.RasterStorageDef = pRasStoreDef
    
    Set createRasterValue = pRasterVal
    
    ' ++ cleanup
    
    Set pRasterVal = Nothing
    Set pRasStoreDef = Nothing
    Exit Function
er:
    MsgBox Err.Description, , "createRasterValue"
    
End Function