<?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, Problem with 0 and CON in ArcGIS Spatial Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333703#M4689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Your interpretation of the Con statement is incorrect. A conditional statement takes the form: IF, THEN, ELSE.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;Using ArcToolbox &amp;gt; Spatial Analyst Tools &amp;gt; Map Algebra &amp;gt; Raster Calculator, it should look like this:&lt;BR /&gt;Con("arroyo_h" == 0, "vcf_tree", (("vcf_tree" / 100) * 0.6) * "arroyo_h")&lt;BR /&gt;&lt;BR /&gt;Translation:&lt;BR /&gt;IF: "arroyo_h" == 0&lt;BR /&gt;THEN: assign value from "vcf_tree"&lt;BR /&gt;ELSE: (("vcf_tree" / 100) * 0.6) * "arroyo_h"&lt;BR /&gt;&lt;BR /&gt;It looks like your rasters are floating point. The default resampling method, performed on the fly, is nearest neighbor. This is not appropriate for floating point rasters and will yield undesirable results. I would recommend resampling your rasters to a consistent resolution prior to analysis. You can find the Resample tool under: Data Management Tools &amp;gt; Raster &amp;gt; Raster Processing &amp;gt; Resample. Under the "Resampling Technique" drop-down select "BILINEAR".&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, this works now, but i use: Con("vcf_tree" == 0, "arroyo_h", (("vcf_tree" / 100) * 0.6) * "arroyo_h") &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;since arroyo_h contains the values that should be changed by vcf_tree or stay unchanged if vcf_tree == 0. But my first results show me that i have to change some things.. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course i tried to build my equation considering the syntax from the help @Stevelynch, but i think this is quite confusing. I did some programming in university, so i know how conditional statements work. The problem is that i still don't understand what the {where clause} is for? And the example from the help (OutRas = Con(InRas1, 40, 30, "Value &amp;gt;= 2")) kind of represents what i tried in my second post, or am i wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually the arroyo_h raster is floating point, the vcf_tree is 8bit unsigned (i think nearest neighbor was the right choice when i reprojected this?), where 0-100 is the percentage of tree coverage, 253 is water (which i still have to filter out of this).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyways, THANK YOU!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Oct 2012 06:46:34 GMT</pubDate>
    <dc:creator>DanielBecker</dc:creator>
    <dc:date>2012-10-10T06:46:34Z</dc:date>
    <item>
      <title>Raster Calculator, Problem with 0 and CON</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333697#M4683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this is a little embarassing but i have the following problem, and i'm sure there's a very simple solution:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to multiply the values of 2 rasters, using one of them as a factor to reduce the values of the first raster.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is, the cells of the second raster contains 0, which, of course, results in 0 in the output-raster, which is wrong. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want the Raster Calculator to do just nothing if this case occurs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope someone can help me!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My calculation looks something like that:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(("second_raster.tif") * 0.6) * "first_raster"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 17:32:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333697#M4683</guid>
      <dc:creator>DanielBecker</dc:creator>
      <dc:date>2012-10-09T17:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator, Problem with 0</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333698#M4684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You'll need to use the Con() function. It would look something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Con("first_raster"=0,"second_raster.tif",(("second_raster.tif") * 0.6) * "first_raster")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the above, if first_raster=0, the result will be whatever is in second_raster.tif, if first_raster not =0, perform equation.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 17:52:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333698#M4684</guid>
      <dc:creator>MarkBoucher</dc:creator>
      <dc:date>2012-10-09T17:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator, Problem with 0</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333699#M4685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your help! I had to change a few things (i think?) because no expression was allowed for the first parameter.. and i think you have to put the condition into the {where clause}? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But it still doesn't work, i even put the vcf_tree raster into my .gdb (which was even weirder.. better don't use "." &amp;gt;8 characters as filename..grr) and now i use this expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Con("vcf_tree",(("vcf_tree" / 100) * 0.6) * "arroyo_h","arroyo_h","Value"&amp;nbsp; &amp;gt; 0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;also tried&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Con("vcf_tree",(("vcf_tree" / 100) * 0.6) * "arroyo_h","arroyo_h","vcf_tree"&amp;nbsp; &amp;gt; 0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But i get this everytime:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;ERROR 000539: Error running expression: rcexec() &amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: ERROR 010416: Error in setting raster table filter for E:\Documents\ArcGIS\Analyse\analyse.gdb\vcf_tree.&lt;BR /&gt;Failed to execute (Con).&lt;BR /&gt;&lt;BR /&gt;Failed to execute (RasterCalculator).&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also both rasters are in different resolution, and i want to use "Minimum of inputs" as cell size.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PS.: Further explanation: i try to change a cost-raster (which contains walking time in hours per cell) by the vegetation index (MODIS VCF).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 20:11:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333699#M4685</guid>
      <dc:creator>DanielBecker</dc:creator>
      <dc:date>2012-10-09T20:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator, Problem with 0 and CON</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333700#M4686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;the syntax (from the help)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Con(in_conditional_raster, in_true_raster_or_constant, {in_false_raster_or_constant}, {where_clause})&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 21:56:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333700#M4686</guid>
      <dc:creator>SteveLynch</dc:creator>
      <dc:date>2012-10-09T21:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator, Problem with 0 and CON</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333701#M4687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your interpretation of the Con statement is incorrect. A conditional statement takes the form: IF, THEN, ELSE.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using ArcToolbox &amp;gt; Spatial Analyst Tools &amp;gt; Map Algebra &amp;gt; Raster Calculator, it should look like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Con("arroyo_h" == 0, "vcf_tree", (("vcf_tree" / 100) * 0.6) * "arroyo_h")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Translation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IF: "arroyo_h" == 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;THEN: assign value from "vcf_tree"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSE: (("vcf_tree" / 100) * 0.6) * "arroyo_h"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks like your rasters are floating point. The default resampling method, performed on the fly, is nearest neighbor. This is not appropriate for floating point rasters and will yield undesirable results. I would recommend resampling your rasters to a consistent resolution prior to analysis. You can find the Resample tool under: Data Management Tools &amp;gt; Raster &amp;gt; Raster Processing &amp;gt; Resample. Under the "Resampling Technique" drop-down select "BILINEAR".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 22:06:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333701#M4687</guid>
      <dc:creator>JeffreyEvans</dc:creator>
      <dc:date>2012-10-09T22:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator, Problem with 0 and CON</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333702#M4688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Steve, and Jeffrey:&amp;nbsp; Thanks for the clarifications. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Daniel:&amp;nbsp;&amp;nbsp; Jeffery's equation should work given the actual layer names.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I usually build the equations using the "pad" in the raster calculator. Had I done that, my "=" would have been "==". The "pad" is handy in that quotes and other syntax can be kept free-er from human error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also the  was a remnant of sloppy cutting and pasting.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 22:22:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333702#M4688</guid>
      <dc:creator>MarkBoucher</dc:creator>
      <dc:date>2012-10-09T22:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator, Problem with 0 and CON</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333703#M4689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Your interpretation of the Con statement is incorrect. A conditional statement takes the form: IF, THEN, ELSE.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;Using ArcToolbox &amp;gt; Spatial Analyst Tools &amp;gt; Map Algebra &amp;gt; Raster Calculator, it should look like this:&lt;BR /&gt;Con("arroyo_h" == 0, "vcf_tree", (("vcf_tree" / 100) * 0.6) * "arroyo_h")&lt;BR /&gt;&lt;BR /&gt;Translation:&lt;BR /&gt;IF: "arroyo_h" == 0&lt;BR /&gt;THEN: assign value from "vcf_tree"&lt;BR /&gt;ELSE: (("vcf_tree" / 100) * 0.6) * "arroyo_h"&lt;BR /&gt;&lt;BR /&gt;It looks like your rasters are floating point. The default resampling method, performed on the fly, is nearest neighbor. This is not appropriate for floating point rasters and will yield undesirable results. I would recommend resampling your rasters to a consistent resolution prior to analysis. You can find the Resample tool under: Data Management Tools &amp;gt; Raster &amp;gt; Raster Processing &amp;gt; Resample. Under the "Resampling Technique" drop-down select "BILINEAR".&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, this works now, but i use: Con("vcf_tree" == 0, "arroyo_h", (("vcf_tree" / 100) * 0.6) * "arroyo_h") &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;since arroyo_h contains the values that should be changed by vcf_tree or stay unchanged if vcf_tree == 0. But my first results show me that i have to change some things.. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course i tried to build my equation considering the syntax from the help @Stevelynch, but i think this is quite confusing. I did some programming in university, so i know how conditional statements work. The problem is that i still don't understand what the {where clause} is for? And the example from the help (OutRas = Con(InRas1, 40, 30, "Value &amp;gt;= 2")) kind of represents what i tried in my second post, or am i wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually the arroyo_h raster is floating point, the vcf_tree is 8bit unsigned (i think nearest neighbor was the right choice when i reprojected this?), where 0-100 is the percentage of tree coverage, 253 is water (which i still have to filter out of this).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyways, THANK YOU!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2012 06:46:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333703#M4689</guid>
      <dc:creator>DanielBecker</dc:creator>
      <dc:date>2012-10-10T06:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator, Problem with 0 and CON</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333704#M4690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A few comments...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The signature for Con in pre ArcGIS 10 is&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; - Con_sa &amp;lt;in_conditional_raster&amp;gt; &amp;lt;in_true_raster_or_constant&amp;gt; &amp;lt;out_raster&amp;gt; {in_false_raster_or_constant} {where_clause}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and from 10 onwards we have output on the left hand side and the signature is&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Con (in_conditional_raster, in_true_raster_or_constant, {in_false_raster_or_constant}, {where_clause})&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the geoprocessing tool exists then one need not use it inside the RasterCalculator tool. However, in some cases you can, for example (in ArcGIS10)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Con("elev", 0, 1, "value &amp;gt; 1000") - where the cell value &amp;gt; 1000 use 0 else use 1 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;can be written in Python or in the RasterCalculator as &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Con(Raster("elev") &amp;gt; 1000, 0, 1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2012 14:47:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-calculator-problem-with-0-and-con/m-p/333704#M4690</guid>
      <dc:creator>SteveLynch</dc:creator>
      <dc:date>2012-10-10T14:47:35Z</dc:date>
    </item>
  </channel>
</rss>

