<?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 Replace values in RGB rasters in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/replace-values-in-rgb-rasters/m-p/316338#M24594</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My goal is to replace the values of one raster (of all the 3 RGB bands) with the values of another raster (also 3 bands) where the values of the initial raster meet some requirements, for example only where Band_1 (Red) = 205, Band_2 (Green) = 255 and Band_3 (Blue) = 194. The code bellow does not work saying something like the raster 205 is not supported...I also dont know how to loop through the RGB arrays...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Initially I tried to do this in raster calculator but did not figure it out how to do it...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here I put the code where I want to replace the values of the Image17 with the values of Image16:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os
arcpy.CheckOutExtension("Spatial")

arcpy.env.workspace = r"Z:\BP\TST"
Image16 = r"Z:\BP\TST\16.tif"
Image17 = r"Z:\BP\TST\17.tif"

Image16_red = arcpy.sa.Raster(Image16+"\\Band_1")
Image16_green = arcpy.sa.Raster(Image16+"\\Band_2")
Image16_blue = arcpy.sa.Raster(Image16+"\\Band_3")


Image17_red = arcpy.sa.Raster(Image17+"\\Band_1")
Image17_green = arcpy.sa.Raster(Image17+"\\Band_2")
Image17_blue = arcpy.sa.Raster(Image17+"\\Band_3")

if Image17_red == "205":
&amp;nbsp;&amp;nbsp;&amp;nbsp; if Image17_green == "255":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Image17_blue == "194":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output_obj = (Image17_red = Image16_red) &amp;amp; (Image17_green = Image16_green) &amp;amp; (Image17_blue = Image16_blue)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output_obj.save(r"Z:\BP\TST\output.tif")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you please give me a hint on how to solve this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Jul 2013 10:06:27 GMT</pubDate>
    <dc:creator>bogdanpalade1</dc:creator>
    <dc:date>2013-07-01T10:06:27Z</dc:date>
    <item>
      <title>Replace values in RGB rasters</title>
      <link>https://community.esri.com/t5/python-questions/replace-values-in-rgb-rasters/m-p/316338#M24594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My goal is to replace the values of one raster (of all the 3 RGB bands) with the values of another raster (also 3 bands) where the values of the initial raster meet some requirements, for example only where Band_1 (Red) = 205, Band_2 (Green) = 255 and Band_3 (Blue) = 194. The code bellow does not work saying something like the raster 205 is not supported...I also dont know how to loop through the RGB arrays...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Initially I tried to do this in raster calculator but did not figure it out how to do it...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here I put the code where I want to replace the values of the Image17 with the values of Image16:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os
arcpy.CheckOutExtension("Spatial")

arcpy.env.workspace = r"Z:\BP\TST"
Image16 = r"Z:\BP\TST\16.tif"
Image17 = r"Z:\BP\TST\17.tif"

Image16_red = arcpy.sa.Raster(Image16+"\\Band_1")
Image16_green = arcpy.sa.Raster(Image16+"\\Band_2")
Image16_blue = arcpy.sa.Raster(Image16+"\\Band_3")


Image17_red = arcpy.sa.Raster(Image17+"\\Band_1")
Image17_green = arcpy.sa.Raster(Image17+"\\Band_2")
Image17_blue = arcpy.sa.Raster(Image17+"\\Band_3")

if Image17_red == "205":
&amp;nbsp;&amp;nbsp;&amp;nbsp; if Image17_green == "255":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Image17_blue == "194":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output_obj = (Image17_red = Image16_red) &amp;amp; (Image17_green = Image16_green) &amp;amp; (Image17_blue = Image16_blue)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output_obj.save(r"Z:\BP\TST\output.tif")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you please give me a hint on how to solve this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 10:06:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-values-in-rgb-rasters/m-p/316338#M24594</guid>
      <dc:creator>bogdanpalade1</dc:creator>
      <dc:date>2013-07-01T10:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values in RGB rasters</title>
      <link>https://community.esri.com/t5/python-questions/replace-values-in-rgb-rasters/m-p/316339#M24595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you use Copy Raster or raster To Other Formats to save your three band composite image as a GRID Stack,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;you will then have access to the three component GRIDs (one for each band).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you run the Reclassify on the GRID (band) you want to change, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and then use Composite Bands to reassemble the composite from the GRIDs,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;you should accomplish what you want to do.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In short:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. disassemble&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. adjust&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. reassemble&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 12:15:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-values-in-rgb-rasters/m-p/316339#M24595</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2013-07-01T12:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Replace values in RGB rasters</title>
      <link>https://community.esri.com/t5/python-questions/replace-values-in-rgb-rasters/m-p/316340#M24596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you very much for your reply. Meanwhile it took like 5 minutes to solve it with erdas model maker :). No need to separate and layer stack after...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 15:10:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replace-values-in-rgb-rasters/m-p/316340#M24596</guid>
      <dc:creator>bogdanpalade1</dc:creator>
      <dc:date>2013-07-01T15:10:55Z</dc:date>
    </item>
  </channel>
</rss>

