Hi everybody! I'm trying to create single band raster from the existing layer(multy-band raster). I'm using C#. Here is the code:
public static void AddRasterLayer(IRaster rasterDataset, IRasterRenderer rasterRenderer)
{
var gisService = new GisService();
var activeView = gisService.GetActiveView();
Service.Gis.GisService.Initialize(Service.Gis.GisService.HookHelper);
var app = Service.Gis.GisService.HookHelper.Hook as IApplication;
//Create a raster layer from a raster dataset. You can also create a raster layer from a raster.
IRasterLayer rasterLayer = new RasterLayerClass();
rasterLayer.CreateFromRaster(rasterDataset);//Set the raster renderer. The default renderer will be used if passing a null value.
if (rasterRenderer != null)
{
rasterLayer.Renderer = rasterRenderer;
}//Add it to a map if the layer is valid.
if (rasterLayer != null)
{
IMap map = activeView.FocusMap;
map.AddLayer(rasterLayer);
}
}
The problem i have is how can i get IRaster and IRasterRenderer objects? Also, is it fine to create single band raster? Thank you for help!