<?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: Con tool: unable to assign constant value for false condition in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/con-tool-unable-to-assign-constant-value-for-false/m-p/586444#M46036</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is the tiff file an integer file?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Jul 2014 03:00:38 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2014-07-23T03:00:38Z</dc:date>
    <item>
      <title>Con tool: unable to assign constant value for false condition</title>
      <link>https://community.esri.com/t5/python-questions/con-tool-unable-to-assign-constant-value-for-false/m-p/586443#M46035</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;I'm attempting to build a tool that will use Con to highlight overlap between two input raster values by producing an output raster with 1s and 0s.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However, even in a most simple form with a single raster and condition I can't seem to assign a constant value for the false condition. The code below results in the error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"0" does not exist&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Currently using 10.2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy
import arcpy.sa as sa

# input raster
ras1 = r"D:\mal\Soil_Type.tif"

# value of ras1 to be evaluated as true
class1 = 3

# Define output layer
ras_output = (r"D:\mal\soils.gdb\soiltype_overlap")

ras3 = sa.Con(ras1 == class1, 1, 0)

ras3.save(ras_output)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can't work out what I am doing wrong here, as the syntax seems to be consistent with all help examples.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any advice appreciated&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Malcolm&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jan 2014 02:11:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/con-tool-unable-to-assign-constant-value-for-false/m-p/586443#M46035</guid>
      <dc:creator>MalcolmNunn</dc:creator>
      <dc:date>2014-01-20T02:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Con tool: unable to assign constant value for false condition</title>
      <link>https://community.esri.com/t5/python-questions/con-tool-unable-to-assign-constant-value-for-false/m-p/586444#M46036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is the tiff file an integer file?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jul 2014 03:00:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/con-tool-unable-to-assign-constant-value-for-false/m-p/586444#M46036</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-07-23T03:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Con tool: unable to assign constant value for false condition</title>
      <link>https://community.esri.com/t5/python-questions/con-tool-unable-to-assign-constant-value-for-false/m-p/586445#M46037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To use the syntax that you have, declare ras1 as a raster (line 5 in your code):&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_14061168014105141" jivemacro_uid="_14061168014105141" modifiedtitle="true"&gt;ras1 = sa.Raster(r"d:\ma1\Soil_Type.tif")
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;then your Con statement should work. Otherwise, I think that Python evaluates ras1 ==&amp;nbsp; class1 as a string comparison.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jul 2014 12:03:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/con-tool-unable-to-assign-constant-value-for-false/m-p/586445#M46037</guid>
      <dc:creator>GregYetman</dc:creator>
      <dc:date>2014-07-23T12:03:57Z</dc:date>
    </item>
  </channel>
</rss>

