I created a new ArcMap Add-in based on your code and it worked just fine - the code was able to add a raster to the ActiveView in ArcMap. See below:
protected override void OnClick()
{ string dir = @C:\Temp\RasterFolder\; // The path to to directory containing the Tiff file string varNh = @Clipped_DEM_Israel.tif; // Name of the Tiff File Type factoryType = Type.GetTypeFromProgID("esriDataSourcesRaster.RasterWorkspaceFactory"); IWorkspaceFactory wsFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); IRasterWorkspace2 rasterWS = (IRasterWorkspace2)wsFactory.OpenFromFile(dir, 0); IRasterDataset rds = rasterWS.OpenRasterDataset(varNh); IRasterLayer rasterLayer = new RasterLayerClass(); rasterLayer.CreateFromDataset(rds); IMap mapa = ArcMap.Document.FocusMap; mapa.AddLayer(rasterLayer); IActiveView activeView = mapa as IActiveView; activeView.Refresh(); }
I performed the test using ArcGIS 10.3.What version of ArcGIS were you using?
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.