This sample shows how to create a raster layer and add it to a map.
How to use
- In ArcMap, call this procedure from VBA.
Sub AddRasterLayer(pRasterDs As IRasterDataset)
'pRasterDs represets a RasterDataset from a raster workspace, an access workspace or an sde workspace.
'Create a raster layer. Use CreateFromRaster method when creating from a Raster.
Dim pRasterLy As IRasterLayer
Set pRasterLy = New RasterLayer
pRasterLy.CreateFromDataset pRasterDs
'Add the raster layer to ArcMap
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
pMxDoc.FocusMap.AddLayer pRasterLy
pMxDoc.ActiveView.Refresh
End Sub