AnsweredAssumed Answered

Create single band raster(layer)

Question asked by lorado on Jul 14, 2017

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();

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();

//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;

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!