<?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 Intermediate raster leads to incorrect final output in arcpy map algebra in ArcGIS Spatial Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/intermediate-raster-leads-to-incorrect-final/m-p/618153#M8982</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to calculate an index&amp;nbsp;and can't figure out why 2 seemingly identical scripts produce very different results. The input raster is a multiband GeoTiff (32-bit float) and I need to use the RGB bands as inputs. The RGB bands first need to be normalized to a scale of 0-1 (e.g. Red/Red_max), then the chromatic coordinates need to be determined (e.g. red/red+green+blue), and finally the index (ExG = 2*green-red-blue).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since my data are already on the 0-1 scale, I can skip that step but still encounter problems. Can someone please explain why this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;red = Float(Raster(inraster+"/Band_1")/(Raster(inraster+"/Band_1")+Raster(inraster+"/Band_2")+Raster(inraster+"/Band_6")))
green = Float(Raster(inraster+"/Band_2")/(Raster(inraster+"/Band_1")+Raster(inraster+"/Band_2")+Raster(inraster+"/Band_6")))
blue = Float(Raster(inraster+"/Band_6")/(Raster(inraster+"/Band_1")+Raster(inraster+"/Band_2")+Raster(inraster+"/Band_6")))
ExG = 2*green - red - blue‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;produces the correct output. But the following does not:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;red = Raster(inraster+"/Band_1")
green = Raster(inraster+"/Band_2")
blue = Raster(inraster+"/Band_6")
red_cc = Float(red/red+green+blue)
green_cc = Float(green/red+green+blue)
blue_cc = Float(blue/red+green+blue)
ExG = 2*green_cc - red_cc - blue_cc‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did the math for a single pixel by hand and the former is definitely correct. Eg.&lt;/P&gt;&lt;P&gt;The original inputs prior to finding the chromatic coordinates are: Red = 0.427023, Green = 0.405449, Blue =0.349515&lt;/P&gt;&lt;P&gt;The ExG calculates to 0.02907.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using the first method, I get 0.029070, but using the second I get&amp;nbsp;0.080466.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 02:24:36 GMT</pubDate>
    <dc:creator>JacobNederend</dc:creator>
    <dc:date>2021-12-12T02:24:36Z</dc:date>
    <item>
      <title>Intermediate raster leads to incorrect final output in arcpy map algebra</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/intermediate-raster-leads-to-incorrect-final/m-p/618153#M8982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to calculate an index&amp;nbsp;and can't figure out why 2 seemingly identical scripts produce very different results. The input raster is a multiband GeoTiff (32-bit float) and I need to use the RGB bands as inputs. The RGB bands first need to be normalized to a scale of 0-1 (e.g. Red/Red_max), then the chromatic coordinates need to be determined (e.g. red/red+green+blue), and finally the index (ExG = 2*green-red-blue).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since my data are already on the 0-1 scale, I can skip that step but still encounter problems. Can someone please explain why this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;red = Float(Raster(inraster+"/Band_1")/(Raster(inraster+"/Band_1")+Raster(inraster+"/Band_2")+Raster(inraster+"/Band_6")))
green = Float(Raster(inraster+"/Band_2")/(Raster(inraster+"/Band_1")+Raster(inraster+"/Band_2")+Raster(inraster+"/Band_6")))
blue = Float(Raster(inraster+"/Band_6")/(Raster(inraster+"/Band_1")+Raster(inraster+"/Band_2")+Raster(inraster+"/Band_6")))
ExG = 2*green - red - blue‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;produces the correct output. But the following does not:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;red = Raster(inraster+"/Band_1")
green = Raster(inraster+"/Band_2")
blue = Raster(inraster+"/Band_6")
red_cc = Float(red/red+green+blue)
green_cc = Float(green/red+green+blue)
blue_cc = Float(blue/red+green+blue)
ExG = 2*green_cc - red_cc - blue_cc‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did the math for a single pixel by hand and the former is definitely correct. Eg.&lt;/P&gt;&lt;P&gt;The original inputs prior to finding the chromatic coordinates are: Red = 0.427023, Green = 0.405449, Blue =0.349515&lt;/P&gt;&lt;P&gt;The ExG calculates to 0.02907.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using the first method, I get 0.029070, but using the second I get&amp;nbsp;0.080466.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:24:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/intermediate-raster-leads-to-incorrect-final/m-p/618153#M8982</guid>
      <dc:creator>JacobNederend</dc:creator>
      <dc:date>2021-12-12T02:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Intermediate raster leads to incorrect final output in arcpy map algebra</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/intermediate-raster-leads-to-incorrect-final/m-p/618154#M8983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The "/" operator in Python and arcpy map algebra does &lt;EM&gt;integer&lt;/EM&gt; division, that is 5 / 3 = 1 &amp;nbsp;(not 1.66) if both operands are integer rasters. You need to float one of the operands:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;rgb &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Float&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;red &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; green &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; blue&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="comment token"&gt;# Float tool (not float)&lt;/SPAN&gt;
red_cc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; red &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; rgb
green_cc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; green &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; rgb
blue_cc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; blue &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; rgb‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/tools/spatial-analyst-toolbox/divide.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/spatial-analyst-toolbox/divide.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Divide—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:24:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/intermediate-raster-leads-to-incorrect-final/m-p/618154#M8983</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-12T02:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Intermediate raster leads to incorrect final output in arcpy map algebra</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/intermediate-raster-leads-to-incorrect-final/m-p/618155#M8984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! This worked so I am marking it as the answer. It did, however, introduce a new problem. The ExG map gets promoted to 64-bit double precision, which unfortunately doesn't work with the Binary Threshold function I need to apply from the Image Analysis Window. I posted about that previously, but never&amp;nbsp;did manage to implement it myself:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/197481-why-does-arcpy-produce-different-results-than-raster-calculatormap-algebra"&gt;https://community.esri.com/thread/197481-why-does-arcpy-produce-different-results-than-raster-calculatormap-algebra&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Aug 2017 01:52:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/intermediate-raster-leads-to-incorrect-final/m-p/618155#M8984</guid>
      <dc:creator>JacobNederend</dc:creator>
      <dc:date>2017-08-19T01:52:48Z</dc:date>
    </item>
  </channel>
</rss>

