How to open a file geodatabase raster dataset


This sample shows how to open a raster Dataset in a File geodatabase.

How to use

  1. Paste this function in your code.
  2. Call this function from your code.
[VBA]
Public Function OpenFGDBRasterDataset(sPath As String, sRasterDatasetName As String) As IRasterDataset
    
    ' Open File geodatabase raster dataset with the given name
    ' sPath is the FGDB path
    ' sRasterDatasetName is the name of the raster Dataset
    
    Dim pWsFact As IWorkspaceFactory2
    Dim pWs As IRasterWorkspaceEx
    Dim pRasterDataset As IRasterDataset
    
    'Open the file geodatabase workspace
    
    Set pWsFact = New FielGDBWorkspaceFactory
    Set pWs = pWsFact.OpenFromFile(sPath, 0)
    
    
    'Open the FGDB raster Dataset
    
    Set pRasterDataset = pWs.OpenRasterDataset(sRasterDatasetName)
    
    
    'Return
    Set OpenFGDBRasterDataset = pRasterDataset
    
    Set pWsFact = Nothing
    Set pWs = Nothing
    Set pRasterDataset = Nothing
    
End Function