I'm having a hard time adding my grid to the map and changing its symbology with an existing lyr file. I have found a great post by Neil Clemmons that explains this, but it doesn't work for me. I tried this code:
Dim map As IMap = pMxDoc.FocusMap' make new layerfile and open lyr file Dim layerFile As ILayerFile = New LayerFileClassDim layerFilePath As String = [my layer file path]layerFile.Open(layerFilePath)Dim layer As ILayer = layerFile.Layer' cast layer to rasterlayer and add grid with content Dim rasterLayer As IRasterLayer = TryCast(layer, IRasterLayer)rasterLayer.CreateFromDataset(overstromingsGridDS)' not able to do this casting with a raster' layerFile.ReplaceContents(CType(overstromingsGridDS, ILayer))layerFile.Save()layerFile.Close()Dim map As IMap = mxDoc.FocusMapmap.AddLayer(layer)The layer gets formatted and added to the map but it seems 'empty'
أكثر...
Dim map As IMap = pMxDoc.FocusMap' make new layerfile and open lyr file Dim layerFile As ILayerFile = New LayerFileClassDim layerFilePath As String = [my layer file path]layerFile.Open(layerFilePath)Dim layer As ILayer = layerFile.Layer' cast layer to rasterlayer and add grid with content Dim rasterLayer As IRasterLayer = TryCast(layer, IRasterLayer)rasterLayer.CreateFromDataset(overstromingsGridDS)' not able to do this casting with a raster' layerFile.ReplaceContents(CType(overstromingsGridDS, ILayer))layerFile.Save()layerFile.Close()Dim map As IMap = mxDoc.FocusMapmap.AddLayer(layer)The layer gets formatted and added to the map but it seems 'empty'


أكثر...