<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Create single band raster(layer) in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/create-single-band-raster-layer/m-p/333796#M2128</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;public static void AddRasterLayer(IRaster rasterDataset, &lt;SPAN style="background-color: #f6f6f6;"&gt;IRasterRenderer rasterRenderer&lt;/SPAN&gt;)&lt;BR /&gt; {&lt;BR /&gt; var gisService = new GisService();&lt;BR /&gt; var activeView = gisService.GetActiveView();&lt;BR /&gt; &lt;BR /&gt; Service.Gis.GisService.Initialize(Service.Gis.GisService.HookHelper);&lt;BR /&gt; var app = Service.Gis.GisService.HookHelper.Hook as IApplication;&lt;BR /&gt; &lt;BR /&gt; //Create a raster layer from a raster dataset. You can also create a raster layer from a raster.&lt;BR /&gt; IRasterLayer rasterLayer = new RasterLayerClass();&lt;BR /&gt; rasterLayer.CreateFromRaster(rasterDataset);&lt;/P&gt;&lt;P&gt;//Set the raster renderer. The default renderer will be used if passing a null value.&lt;BR /&gt; if (rasterRenderer != null)&lt;BR /&gt; {&lt;BR /&gt; rasterLayer.Renderer = rasterRenderer;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;//Add it to a map if the layer is valid.&lt;BR /&gt; if (rasterLayer != null)&lt;BR /&gt; {&lt;BR /&gt; IMap map = activeView.FocusMap;&lt;BR /&gt; map.AddLayer(rasterLayer);&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;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!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Jul 2017 11:15:38 GMT</pubDate>
    <dc:creator>MaxMedvedenko</dc:creator>
    <dc:date>2017-07-14T11:15:38Z</dc:date>
    <item>
      <title>Create single band raster(layer)</title>
      <link>https://community.esri.com/t5/developers-questions/create-single-band-raster-layer/m-p/333796#M2128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;public static void AddRasterLayer(IRaster rasterDataset, &lt;SPAN style="background-color: #f6f6f6;"&gt;IRasterRenderer rasterRenderer&lt;/SPAN&gt;)&lt;BR /&gt; {&lt;BR /&gt; var gisService = new GisService();&lt;BR /&gt; var activeView = gisService.GetActiveView();&lt;BR /&gt; &lt;BR /&gt; Service.Gis.GisService.Initialize(Service.Gis.GisService.HookHelper);&lt;BR /&gt; var app = Service.Gis.GisService.HookHelper.Hook as IApplication;&lt;BR /&gt; &lt;BR /&gt; //Create a raster layer from a raster dataset. You can also create a raster layer from a raster.&lt;BR /&gt; IRasterLayer rasterLayer = new RasterLayerClass();&lt;BR /&gt; rasterLayer.CreateFromRaster(rasterDataset);&lt;/P&gt;&lt;P&gt;//Set the raster renderer. The default renderer will be used if passing a null value.&lt;BR /&gt; if (rasterRenderer != null)&lt;BR /&gt; {&lt;BR /&gt; rasterLayer.Renderer = rasterRenderer;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;//Add it to a map if the layer is valid.&lt;BR /&gt; if (rasterLayer != null)&lt;BR /&gt; {&lt;BR /&gt; IMap map = activeView.FocusMap;&lt;BR /&gt; map.AddLayer(rasterLayer);&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;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!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Jul 2017 11:15:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/create-single-band-raster-layer/m-p/333796#M2128</guid>
      <dc:creator>MaxMedvedenko</dc:creator>
      <dc:date>2017-07-14T11:15:38Z</dc:date>
    </item>
  </channel>
</rss>

