HOW TO
This document shows how to programmatically add a raster catalog to ArcMap.
Note:
Code in the Project's ThisDocument code module will run only in the current map document. To store the code in all map documents, open the Normal.mxt ThisDocument code module instead.
Code:
Sub AddRasterCatalog()
Dim pWF As IWorkspaceFactory
Set pWF = New ArcInfoWorkspaceFactory
Dim pWS As IFeatureWorkspace
'Open the INFO table.
Set pWS = pWF.OpenFromFile("c:\temp", 0)
Dim pTable As ITable
Set pTable = pWS.OpenTable("MyTable")
'Create and Update the Raster Table
Dim pRT As IRasterCatalogTable
Set pRT = New RasterCatalogTable
Set pRT.Table = pTable
pRT.Update
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
Dim pMap As IMap
Set pMap = pDoc.FocusMap
'Create the Raster Layer and add it to ArcMap
Dim pRLayer As IRasterCatalogLayer
Set pRLayer = New RasterCatalogLayer
pRLayer.Create pRT
pRLayer.DisplayRasters = True
pMap.AddLayer pRLayer
pRLayer.Draw esridpgeograpy, pDoc.ActiveView.ScreenDisplay, Nothing
pDoc.ActiveView.Refresh
End Sub
Article ID:000004969
Get help from ArcGIS experts
Download the Esri Support App