How to open a personal geodatabase raster dataset


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

How to use

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