This sample shows how to open a raster dataset from a file.
How to use
- Add this function to your project.
- Call this function from your code, passing in appropriate arguments.
Public Function OpenRasterDataset(sDir As String, sFile As String) As IRasterDataset
'Open the raster dataset with the given name.
'sDir is the directory the file resides
'sFile is the filename
Dim pWsFact As IWorkspaceFactory
Dim pWs As IRasterWorkspace
Dim pRasterDataset As IRasterDataset
'Open the workspace
Set pWsFact = New RasterWorkspaceFactory
Set pWs = pWsFact.OpenFromFile(sDir, 0)
'Open the raster dataset
Set pRasterDataset = pWs.OpenRasterDataset(sFile)
'Return
Set OpenRasterDataset = pRasterDataset
Set pWsFact = Nothing
Set pWs = Nothing
Set pRasterDataset = Nothing
End Function