lnnga

Adding a raster to ArcMap problem in VB.net

Discussion created by lnnga on Aug 12, 2011
Latest reply on Aug 15, 2011 by lnnga
I can add a raster to ArcMap via VB.net but the added raster doesnt show up any thing on the ArcMap. Please see two figures attached here: (1) the raster data opened directly in the ArcMap, (2) the raster data opened through VB.net codes.

I could not find the problem in my codes (I am using ArcGIS Desktop 9.3.1, W7, VS2008).


Private Sub addRaster2ArcMap()
        Dim m_pDoc As IDocument = New ESRI.ArcGIS.ArcMapUI.MxDocument()
        Dim m_pApp As IApplication

        ' Get a reference to the application
        m_pApp = m_pDoc.Parent
      
        'Create a raster layer
        Dim dsFolder As String = "D:\TT-Hue\01_GIS\NgapLut VN2000\"
        Dim rasterName As String = "d100y"
      
        Dim pRasterLy As IRasterLayer = New RasterLayer()
        pRasterLy.CreateFromFilePath(dsFolder & rasterName)

        'Add the raster layer to ArcMap
        Dim mxDoc As IMxDocument = CType(m_pApp.Document, IMxDocument)
        Dim map As IMap = mxDoc.FocusMap
        map.AddLayer(CType(pRasterLy, ILayer))
        mxDoc.ActiveView.Refresh()
        mxDoc.UpdateContents()


    End Sub


I am looking forwards to seeing your solution soon.

Regards

Nga Le

Attachments

Outcomes