<?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 Re: Raster Calculator help in ArcGIS Spatial Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524933#M7608</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might do better looking at the Con Spatial Analyst tool help, since that is the tool that is being used inside raster calculator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But yes, your syntax looks correct, you are evaluating&amp;nbsp; if the value of the cell of Band1 is 255 and Band2 is 255 and Band 3 is 255, make it a 1, otherwise zero.&amp;nbsp; I might put all the &amp;amp; statements in parentheses as well if it is not working properly. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Sep 2014 17:37:14 GMT</pubDate>
    <dc:creator>IanMurray</dc:creator>
    <dc:date>2014-09-24T17:37:14Z</dc:date>
    <item>
      <title>Raster Calculator help</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524931#M7606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it me or is the Raster Calculator help rather vague?&amp;nbsp; I'm looking at the Conditional oporators and I can't see anywhere that tells me what they do and what syntax they want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway what I'm trying to do is take my 3 band colour tiff and say&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if the colour is white make the value 1 and make everything else 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so I've guessed that Con means Conditional and have written this in the raster calculator:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Con(("mytif.tif.Band1"==255) &amp;amp; ("mytif.tif.Band2"==255) &amp;amp; ("mytif.tif.Band3"==255), 1, 0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can anyone help?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Sep 2014 14:40:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524931#M7606</guid>
      <dc:creator>BenLeslie1</dc:creator>
      <dc:date>2014-09-24T14:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator help</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524932#M7607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;don't have an image to test, but did you get an error message?&amp;nbsp; Did you type this in manually? I would expect a space on either side of the equality check&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Sep 2014 16:30:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524932#M7607</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-09-24T16:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator help</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524933#M7608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might do better looking at the Con Spatial Analyst tool help, since that is the tool that is being used inside raster calculator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But yes, your syntax looks correct, you are evaluating&amp;nbsp; if the value of the cell of Band1 is 255 and Band2 is 255 and Band 3 is 255, make it a 1, otherwise zero.&amp;nbsp; I might put all the &amp;amp; statements in parentheses as well if it is not working properly. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Sep 2014 17:37:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524933#M7608</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-09-24T17:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator help</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524934#M7609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried it with a screen dump saved as TIFF and it worked for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Executing: RasterCalculator Con(("mytif.tif - Band_1"==255) &amp;amp; ("mytif.tif - Band_2"==255) &amp;amp; ("mytif.tif - Band_3"==255), 1, 0) D:\Xander\tmp\NIData.gdb\bla&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Start Time: Wed Sep 24 14:28:01 2014&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Con((Raster(r"mytif.tif - Band_1")==255) &amp;amp; (Raster(r"mytif.tif - Band_2")==255) &amp;amp; (Raster(r"mytif.tif - Band_3")==255), 1, 0)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Succeeded at Wed Sep 24 14:28:08 2014 (Elapsed Time: 7,00 seconds)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you look closely the bands in my TIFF are called differently. I did not add the TIFF to the TOC, but the bands inside the TIFF to the TOC. There is no need to use spaces right around the equal sings (that used to be necessary when using float rasters, but the bands are integer).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Sep 2014 19:32:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524934#M7609</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-09-24T19:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator help</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524935#M7610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;EM&gt;&amp;gt; Is it me or is the Raster Calculator help rather vague?&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;There are many, many raster tools - and unlike 9.x the tool and raster calculator functions and tools have the same syntax - so there is no need to document them twice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I recommend reading with the help article:&amp;nbsp; &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00p600000002000000"&gt;What is Map Algebra?&lt;/A&gt;‌ I know there's a lot of detail to wade through, but when you get the hang of it there is a lot of power (and efficiency) in stringing the tools together in map algebra expressions!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Personally, I really like to leave spaces around all operators when working in Python. Both these are legal Python but which would you rather read and debug?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Con(("mytif.tif - Band_1"==255)&amp;amp;("mytif.tif - Band_2"==255)&amp;amp;("mytif.tif - Band_3"==255),1,0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Con(("mytif.tif - Band_1" == 255) &amp;amp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ("mytif.tif - Band_2" == 255) &amp;amp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ("mytif.tif - Band_3" == 255), 1, 0)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 05:54:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524935#M7610</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2014-09-25T05:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator help</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524936#M7611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks guys.&lt;/P&gt;&lt;P&gt;Just a note to any other novices reading this - I was testing a concept in Raster Calculator.&amp;nbsp; When I came to write my batch script the notation is different...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14116323995508377" jivemacro_uid="_14116323995508377" modifiedtitle="true"&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myRaster = "blah_blah.tif"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #band notation is a backslash&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; redband = myRaster + "\Band_1"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; greenband = myRaster + "\Band_2"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; blueband = myRaster + "\Band_3"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #need to remind it that each input is a raster&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = Con((Raster(redband)==255) &amp;amp; (Raster(greenband)==255) &amp;amp; (Raster(blueband)==255),1,0)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster.save("C:/OutputFolder/" + myRaster)&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 08:07:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524936#M7611</guid>
      <dc:creator>BenLeslie1</dc:creator>
      <dc:date>2014-09-25T08:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator help</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524937#M7612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're absolutely right, you can use Python for this purpose too and the syntax will be slightly different. It depend on where the code is executed. Your script sample would work as standalone too (after including the import and setting the workspace). The syntax that was returned by the Raster Calculator Tool uses the existence of the TOC and how the rasters are called there (example: "&lt;EM&gt;mytif.tif - Band_1&lt;/EM&gt;").&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your script you use the slash, and that indicates that the TIFF is considered a dataset and the bands are rasters within the dataset. A small script to explain what I mean:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14116482885153455 jive_text_macro" jivemacro_uid="_14116482885153455"&gt;
&lt;P&gt;import arcpy&lt;/P&gt;
&lt;P&gt;import os&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;folder = r"D:\Xander\GeoNet\TIFF_CON"&lt;/P&gt;
&lt;P&gt;arcpy.env.workspace = folder&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;lst_ds = arcpy.ListDatasets()&lt;/P&gt;
&lt;P&gt;for ds in lst_ds:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "dataset: {0}".format(ds)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = os.path.join(folder, ds)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_ras = arcpy.ListRasters()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for ras in lst_ras:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "raster: {0}".format(ras)&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Results in:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14116482998417035" jivemacro_uid="_14116482998417035"&gt;
&lt;P&gt;dataset: mytif.tif&lt;/P&gt;
&lt;P&gt;raster: Band_1&lt;/P&gt;
&lt;P&gt;raster: Band_2&lt;/P&gt;
&lt;P&gt;raster: Band_3&lt;/P&gt;
&lt;P&gt;raster: Band_4&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My folder where the TIFF resides is my initial workspace. When I list the datasets in that workspace it will find the TIFF, setting the TIFF as workspace allows me to list the rasters (the bands inside the TIFF). If you would like to access the rasterbands without setting the workspace to your TIFF you would have to "join" the folder, dataset (TIFF) and each rasterband:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_1411648550183360" jivemacro_uid="_1411648550183360"&gt;
&lt;P&gt;redband = os.path.join(folder, NameOfYourTIFF, "Band_1")&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;And yes, defining raster objects allows for much easier syntax. For instance I you want to sum 3 rasters without defining the individual rasters as raster objects you would have to use a nested arcpy.sa.Plus tool. If you define the rasters as raster objects you can simply use the + sign to sum them.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 12:41:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-help/m-p/524937#M7612</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-09-25T12:41:20Z</dc:date>
    </item>
  </channel>
</rss>

