Add a Raster Layer to ArcMap

Created:1/25/2002
Description:

This sample shows how one can create a raster layer and add it to ArcMap.

How to use:
  1. Call this procedure from VBA.
Sub AddRasterLayer(sPath As String, sFileName As String)
    'sFileName: the filename of the raster dataset
    'sPath: the directory where the raster dataset resides
           
    'Create a raster layer
    Dim pRasterLy As IRasterLayer
    Set pRasterLy = New RasterLayer
    'This is only one of the three ways to create a RasterLayer object.
    'If there is already a Raster or RasterDataset object, then
    ' method CreateFromDataset or CreateFromRaster can be used.
    pRasterLy.CreateFromFilePath sPath + sFileName
   
    'Add the raster layer to ArcMap
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    Dim pMap As IMap
    Set pMap = pMxDoc.FocusMap
    pMap.AddLayer pRasterLy
    pMxDoc.ActiveView.Refresh
End Sub