We have several TIFF images (already tagged with position information) we want to load as a single layer into the map. It's the first time I dig into this raster/topology thing, but at least I managed to create a layer with one image as an
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesRaster.RasterWorkspaceFactory"); IWorkspaceFactory wsFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType); IRasterWorkspace2 rasterWS = (IRasterWorkspace2)wsFactory.OpenFromFile(@"c:\sourcefiles\"); IRasterDataset rds = rasterWS.OpenRasterDataset(@"example.tif"); IRasterLayer rasterLayer = new RasterLayerClass(); rasterLayer.CreateFromDataset(rds); _map.AddLayer(rasterLayer);
This works well but I need to add all TIFF files to this raster layer. So I assume that
IRasterCatalog could suit my needs. But my attempt to use it fails already on creation of the catalog object (taken from sample):
Geoprocessor geoProcessor = new Geoprocessor(); CreateRasterCatalog createRasterCatalog = new ESRI.ArcGIS.DataManagementTools.CreateRasterCatalog(); //Set parameters createRasterCatalog.out_path = outPath; createRasterCatalog.out_name = catalogName; createRasterCatalog.raster_spatial_reference = map.SpatialReference; createRasterCatalog.spatial_reference = = map.SpatialReference; //Execute the tool to create a raster catalog geoProcessor.Execute(createRasterCatalog, null);
On Exceute() I get a COMException, which isn't very helpfull. I tried to set the SpatialReference to
IGPCoordinateSystem objects. I made sure that the output path exists.
Still the COMException raises. Has anyone a clue for me?
Is this the right approach at all?