<?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: Use Con with two rasters in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074677#M25650</link>
    <description>&lt;P&gt;Hi Dan&lt;/P&gt;&lt;P&gt;Please read my previous question here:&amp;nbsp;&lt;A href="https://community.esri.com/t5/python-questions/what-is-the-way-to-call-spatial-analysis-tools-in-arcmap-from/td-p/1037005" target="_blank"&gt;https://community.esri.com/t5/python-questions/what-is-the-way-to-call-spatial-analysis-tools-in-arcmap-from/td-p/1037005&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The arcpy.sa.con_sa have different parameters and the first parameter is the input raster so you cannot gives two rasters.&lt;/P&gt;&lt;P&gt;I will look into the numpy&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jul 2021 13:24:26 GMT</pubDate>
    <dc:creator>mody_buchbinder</dc:creator>
    <dc:date>2021-07-01T13:24:26Z</dc:date>
    <item>
      <title>Use Con with two rasters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074140#M25643</link>
      <description>&lt;P&gt;Hello all&lt;/P&gt;&lt;P&gt;I am trying to write a python program that will create a new raster by condition of two rasters.&lt;/P&gt;&lt;P&gt;I can do it with the con function like this:&lt;/P&gt;&lt;P&gt;res = arcpy.sa.Con((Raster1 == 0 &amp;amp; Raster2 == 0),1,0)&lt;/P&gt;&lt;P&gt;For the con function you need to create a Raster() before you can use it and then save the results.&lt;/P&gt;&lt;P&gt;From the other hand arcpy.gp.con_sa&amp;nbsp; can get a path of tif as parameter and the final result name is parameter.&lt;/P&gt;&lt;P&gt;I could not find the way to put two rasters in the condition (it is usually "value == 0" of the raster in the new parameter.&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 13:35:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074140#M25643</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2021-06-30T13:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Use Con with two rasters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074171#M25644</link>
      <description>&lt;P&gt;Not sure if I am able to understand the concern.&lt;/P&gt;&lt;P&gt;Are you looking for an expression like?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.sa.Con(((Raster1 == 0) &amp;amp; (Raster2 == 0)), 1, 0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 14:30:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074171#M25644</guid>
      <dc:creator>JayantaPoddar</dc:creator>
      <dc:date>2021-06-30T14:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Use Con with two rasters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074191#M25645</link>
      <description>&lt;P&gt;What do you mean by python program? If you mean as a python script tool, can't the output filename when using .save() just be used as a parameter?&amp;nbsp; If you mean as a GP tool/task, then the result object of .save() would just be put as arcpy.SetParameter(x) and the output set as derived (a while since I've done that so may not be exactly correct).&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 14:59:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074191#M25645</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-06-30T14:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Use Con with two rasters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074192#M25646</link>
      <description>&lt;P&gt;Did you try something like this... pick one or the other to see if it works... they lead to the same code in any event&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;r0 = "c:/path/some.tif"
r1 = "c:/path/another.tif"
arcpy.gp.con_sa((Raster(r0) == 0) &amp;amp; (Raster(r1) == 0), 1, 0)
# ---- or!!
arcpy.sa.Con((Raster(r0) == 0) &amp;amp; (Raster(r1) == 0), 1, 0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 15:04:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074192#M25646</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-06-30T15:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: Use Con with two rasters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074203#M25647</link>
      <description>&lt;P&gt;or a numpy lesson... verbose, showing that arcpy plays nice with numpy&lt;/P&gt;&lt;LI-CODE lang="python"&gt;a1 = arcpy.RasterToNumPyArray("c:/temp/a0.tif")
b1 = arcpy.RasterToNumPyArray("c:/temp/b0.tif")
whr = np.logical_and((a1==0), (b1==0))
out = np.where(whr, 1, 0)

a1 
array([[1, 0, 3, 0],
       [3, 2, 1, 1],
       [4, 3, 0, 3],
       [2, 0, 0, 1],
       [2, 4, 2, 1]])

b1 
array([[1, 1, 2, 4],
       [3, 1, 0, 3],
       [4, 2, 0, 1],
       [3, 4, 1, 2],
       [1, 0, 2, 0]])

whr 
array([[False, False, False, False],
       [False, False, False, False],
       [False, False,  True, False],
       [False, False, False, False],
       [False, False, False, False]])

out
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])&lt;/LI-CODE&gt;&lt;P&gt;my favorite raster goto &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 15:16:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074203#M25647</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-06-30T15:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Use Con with two rasters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074677#M25650</link>
      <description>&lt;P&gt;Hi Dan&lt;/P&gt;&lt;P&gt;Please read my previous question here:&amp;nbsp;&lt;A href="https://community.esri.com/t5/python-questions/what-is-the-way-to-call-spatial-analysis-tools-in-arcmap-from/td-p/1037005" target="_blank"&gt;https://community.esri.com/t5/python-questions/what-is-the-way-to-call-spatial-analysis-tools-in-arcmap-from/td-p/1037005&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The arcpy.sa.con_sa have different parameters and the first parameter is the input raster so you cannot gives two rasters.&lt;/P&gt;&lt;P&gt;I will look into the numpy&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 13:24:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074677#M25650</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2021-07-01T13:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Use Con with two rasters</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074705#M25651</link>
      <description>&lt;P&gt;Mody, if you want to bring the raster back in, check the optional parameters for rastertonumpyarray and numpyarraytoraster&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/rastertonumpyarray-function.htm" target="_blank"&gt;RasterToNumPyArray—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;RasterToNumPyArray (in_raster, {lower_left_corner}, {ncols}, {nrows}, {nodata_to_value})&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/numpyarraytoraster-function.htm" target="_blank"&gt;NumPyArrayToRaster—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;NumPyArrayToRaster (in_array, {lower_left_corner}, {x_cell_size}, {y_cell_size}, {value_to_nodata}, {mdinfo})&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This allows you to maintain the spatial location and nodata values.&lt;/P&gt;&lt;P&gt;the lower left corner has examples in the help eg&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;lowerLeft = arcpy.Point(in_raster.extent.XMin, in_raster.extent.YMin)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 14:17:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/use-con-with-two-rasters/m-p/1074705#M25651</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-07-01T14:17:01Z</dc:date>
    </item>
  </channel>
</rss>

