<?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 for Python Script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737606#M57068</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; Still didn't work &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;I'm setting the workspace here:&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;env.workspace = FD_addr&amp;nbsp; &lt;BR /&gt;list = arcpy.ListRasters("*", "ALL")&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;(not sure how you make it so that code appears in gray?)&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;I feel that has to be working because the rasters being inserted into list are the rasters in that location (I double checked.)&amp;nbsp; &lt;BR /&gt;FD_addr is set way in the beginning of the code.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Interesting. Are you sure you hard-coded it to an "existing" FGDB? If so, what do you mean it didn't work? Didn't create the raster with your hard-coded name, created a blank raster? Error messages?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What does it report if make the modifications in red?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os
arcpy.CheckOutExtension('Spatial')
arcpy.AddMessage("Creating Elevation Raster")
arcpy.env.workspace = FD_addr
list = arcpy.ListRasters("*", "ALL")
raster0 = arcpy.Raster(list[0])
raster1 = arcpy.Raster(list[1])
elevation = arcpy.sa.Con(raster1 - raster0 &amp;gt;= 0, raster1 - rasters0, 0)
&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;print "temporary: ",elevation.isTemporary&lt;/SPAN&gt;
elevation.save(FD_addr)
&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;print "temporary: ",elevation.isTemporary&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, it looks like elevation.save(FD_addr) is telling it to save with the filename of the workspace. Workspace is normally a folder or FGDB, not a file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It's my understanding that elevation.save() would save it in the current workspace as raster dataset "elevation".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now that I think about it, before trying the above code, what happens if you try this (of course, make sure the FD_addr is set to a FGDB that the current user has write access to):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os
arcpy.CheckOutExtension('Spatial')
arcpy.AddMessage("Creating Elevation Raster")
arcpy.env.workspace = FD_addr
list = arcpy.ListRasters("*", "ALL")
raster0 = arcpy.Raster(list[0])
raster1 = arcpy.Raster(list[1])
elevation = arcpy.sa.Con(raster1 - raster0 &amp;gt;= 0, raster1 - rasters0, 0)
&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;elevation.save()
&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 07:25:00 GMT</pubDate>
    <dc:creator>RhettZufelt</dc:creator>
    <dc:date>2021-12-12T07:25:00Z</dc:date>
    <item>
      <title>Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737598#M57060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I cannot get a conditional evaluation calculation to be done on two rasters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want an ouput raster to be created from the positive difference of two rasters (so no negative numbers)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The part of the code that isn't working&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy.sa import *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CheckOutExtension('Spatial')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried &lt;/SPAN&gt;&lt;STRONG&gt;two different ways, both failing&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Method one&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Creating Elevation Raster")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; env.workspace = FD_addr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; list = arcpy.ListRasters("*", "ALL")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; elevation = Con(list[1]-list[0]&amp;gt;=0, list[1]-list[0],0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; elevation.save(FD_addr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Method two&lt;/STRONG&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; arcpy.AddMessage("Creating Elevation Raster")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; expression = "Con({}-{}&amp;gt;=0, {}-{},0)".format(list[1], list[0], list[1], list[0])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; OR = "elevation3"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; OutRaster = os.join.path(FD_addr,OR)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; gp = arcgisscripting.create()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; gp.SingleOutputMapAlgebra_sa(expression, OutRaster)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;my list has two rasters (I've checked to make sure they are there): a DSM and a DEM, and I want to find the positive elevation difference between the two.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Any help would be appreciated! I've been stuck on this for ages.&lt;/STRONG&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jun 2013 14:56:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737598#M57060</guid>
      <dc:creator>SAC_PhySAC_Phy</dc:creator>
      <dc:date>2013-06-27T14:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737599#M57061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The inputs need to be "raster objects" to work in teh new map algebra. Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
arcpy.CheckOutExtension('Spatial')
arcpy.AddMessage("Creating Elevation Raster")
arcpy.env.workspace = FD_addr
list = arcpy.ListRasters("*", "ALL")
raster0 = arcpy.Raster(list[0])
raster1 = arcpy.Raster(list[1])
elevation = arcpy.sa.Con(raster1 - raster0 &amp;gt;= 0, raster1 - rasters0, 0)
elevation.save(FD_addr)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:24:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737599#M57061</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-12T07:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737600#M57062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The inputs need to be "raster objects" to work in teh new map algebra. Try this:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
arcpy.CheckOutExtension('Spatial')
arcpy.AddMessage("Creating Elevation Raster")
arcpy.env.workspace = FD_addr
list = arcpy.ListRasters("*", "ALL")
raster0 = arcpy.Raster(list[0])
raster1 = arcpy.Raster(list[1])
elevation = arcpy.sa.Con(raster1 - raster0 &amp;gt;= 0, raster1 - rasters0, 0)
elevation.save(FD_addr)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;While this went through without giving any error message, no raster was created (or saved?).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:24:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737600#M57062</guid>
      <dc:creator>SAC_PhySAC_Phy</dc:creator>
      <dc:date>2021-12-12T07:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737601#M57063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yep - on the last line try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;elevation.save("my_output")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The raster "my_output" should then be saved to the 'FD_addr' workspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Question though: Does 'FD_addr' point to a feature dataset within a geodatabase? Last I checked, I thought that you can't write rasters to a feature dataset (has to be directly to the GDB).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jun 2013 15:56:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737601#M57063</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2013-06-27T15:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737602#M57064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Yep - on the last line try:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;elevation.save("my_output")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;The raster "my_output" should then be saved to the 'FD_addr' workspace.&lt;BR /&gt;&lt;BR /&gt;Question though: Does 'FD_addr' point to a feature dataset within a geodatabase? Last I checked, I thought that you can't write rasters to a feature dataset (has to be directly to the GDB).&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tried both &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; elevation.save("my_output")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; my_output.save(FD_addr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; "my_output".save(FD_addr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But again, neither worked/saved.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;FD_addr is really just bad naming on my behalf. This is part of something much larger, and when I first began this, I had intended for FD_addr to be the location inside the (file) geodatabase where the feature dataset would be created..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So FD_addr points to within the geodatabase and not within the feature dataset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bad naming, I know...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But I have other rasters being created with FD_addr as their output address and they do indeed go to the correct spot.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jun 2013 16:12:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737602#M57064</guid>
      <dc:creator>SAC_PhySAC_Phy</dc:creator>
      <dc:date>2013-06-27T16:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737603#M57065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't see in the code anywhere that you are setting the variable 'FD_addr' (maybe it is above the imports somewhere?) to actually set the env.workspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could try somehting like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
elevation.save("C:/output/file_gdb.gdb/elevation")&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # or whatever the path/filename you want for your out raster
&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If this works, at least then you know it's an issue with the workspace/path being set properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:24:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737603#M57065</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-12T07:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737604#M57066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I don't see in the code anywhere that you are setting the variable 'FD_addr' (maybe it is above the imports somewhere?) to actually set the env.workspace.&lt;BR /&gt;&lt;BR /&gt;Could try somehting like:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
elevation.save("C:/output/file_gdb.gdb/elevation")&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # or whatever the path/filename you want for your out raster
&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;BR /&gt; &lt;BR /&gt;If this works, at least then you know it's an issue with the workspace/path being set properly.&lt;BR /&gt;&lt;BR /&gt;R_&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Still didn't work &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm setting the workspace here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = FD_addr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;list = arcpy.ListRasters("*", "ALL")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(not sure how you make it so that code appears in gray?)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I feel that has to be working because the rasters being inserted into list are the rasters in that location (I double checked.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FD_addr is set way in the beginning of the code.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:24:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737604#M57066</guid>
      <dc:creator>SAC_PhySAC_Phy</dc:creator>
      <dc:date>2021-12-12T07:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737605#M57067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;&lt;BR /&gt;(not sure how you make it so that code appears in gray?)&lt;BR /&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code"&gt;http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code&lt;/A&gt;&lt;SPAN&gt; &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jun 2013 19:12:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737605#M57067</guid>
      <dc:creator>MattSayler</dc:creator>
      <dc:date>2013-06-27T19:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737606#M57068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; Still didn't work &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;I'm setting the workspace here:&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;env.workspace = FD_addr&amp;nbsp; &lt;BR /&gt;list = arcpy.ListRasters("*", "ALL")&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;(not sure how you make it so that code appears in gray?)&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;I feel that has to be working because the rasters being inserted into list are the rasters in that location (I double checked.)&amp;nbsp; &lt;BR /&gt;FD_addr is set way in the beginning of the code.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Interesting. Are you sure you hard-coded it to an "existing" FGDB? If so, what do you mean it didn't work? Didn't create the raster with your hard-coded name, created a blank raster? Error messages?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What does it report if make the modifications in red?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os
arcpy.CheckOutExtension('Spatial')
arcpy.AddMessage("Creating Elevation Raster")
arcpy.env.workspace = FD_addr
list = arcpy.ListRasters("*", "ALL")
raster0 = arcpy.Raster(list[0])
raster1 = arcpy.Raster(list[1])
elevation = arcpy.sa.Con(raster1 - raster0 &amp;gt;= 0, raster1 - rasters0, 0)
&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;print "temporary: ",elevation.isTemporary&lt;/SPAN&gt;
elevation.save(FD_addr)
&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;print "temporary: ",elevation.isTemporary&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, it looks like elevation.save(FD_addr) is telling it to save with the filename of the workspace. Workspace is normally a folder or FGDB, not a file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It's my understanding that elevation.save() would save it in the current workspace as raster dataset "elevation".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now that I think about it, before trying the above code, what happens if you try this (of course, make sure the FD_addr is set to a FGDB that the current user has write access to):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os
arcpy.CheckOutExtension('Spatial')
arcpy.AddMessage("Creating Elevation Raster")
arcpy.env.workspace = FD_addr
list = arcpy.ListRasters("*", "ALL")
raster0 = arcpy.Raster(list[0])
raster1 = arcpy.Raster(list[1])
elevation = arcpy.sa.Con(raster1 - raster0 &amp;gt;= 0, raster1 - rasters0, 0)
&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;elevation.save()
&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:25:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737606#M57068</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-12T07:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737607#M57069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It doesn't report anything. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure how I see command line messages (I'm very new to this.) The only messages I can see are the ones I code in by arcpy.AddMessage("Message")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the first option didn't give me any message (though I tried it with the arcpy.AddMessage() as well) and I tried elevation.save()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have since changed it to elevation.save("elevation") because I figured it needed the name to save the raster to since the workspace was already set and knew where to save.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I assume I have writing privileges because before this I have a terrain to raster method, and the terrains are being saved to the same location as I'm trying to save this raster (FD_addr), but this is before I set the workspace. I only set the workspace because I wanted a list created with the rasters that are saved in the FD_addr location. So unless setting the workspace alters the writing privilege, I assume I can write files to that location.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm still at a loss. I feel like I've tried so many options and still don't know what's wrong or how to fix this. It seems as if it should work!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; Interesting. Are you sure you hard-coded it to an "existing" FGDB? If so, what do you mean it didn't work? Didn't create the raster with your hard-coded name, created a blank raster? Error messages?&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;What does it report if make the modifications in red?&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; &lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os
arcpy.CheckOutExtension('Spatial')
arcpy.AddMessage("Creating Elevation Raster")
arcpy.env.workspace = FD_addr
list = arcpy.ListRasters("*", "ALL")
raster0 = arcpy.Raster(list[0])
raster1 = arcpy.Raster(list[1])
elevation = arcpy.sa.Con(raster1 - raster0 &amp;gt;= 0, raster1 - rasters0, 0)
&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;print "temporary: ",elevation.isTemporary&lt;/SPAN&gt;
elevation.save(FD_addr)
&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;print "temporary: ",elevation.isTemporary&lt;/SPAN&gt;
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;R_&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;Also, it looks like elevation.save(FD_addr) is telling it to save with the filename of the workspace. Workspace is normally a folder or FGDB, not a file.&amp;nbsp; &lt;BR /&gt;It's my understanding that elevation.save() would save it in the current workspace as raster dataset "elevation".&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt;Now that I think about it, before trying the above code, what happens if you try this (of course, make sure the FD_addr is set to a FGDB that the current user has write access to):&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; &lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os
arcpy.CheckOutExtension('Spatial')
arcpy.AddMessage("Creating Elevation Raster")
arcpy.env.workspace = FD_addr
list = arcpy.ListRasters("*", "ALL")
raster0 = arcpy.Raster(list[0])
raster1 = arcpy.Raster(list[1])
elevation = arcpy.sa.Con(raster1 - raster0 &amp;gt;= 0, raster1 - rasters0, 0)
&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;elevation.save()
&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:25:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737607#M57069</guid>
      <dc:creator>SAC_PhySAC_Phy</dc:creator>
      <dc:date>2021-12-12T07:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737608#M57070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So this is what the part of the code that isn't creating the raster looks like (libraries and extensions included)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import arcpy
import os
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial") # for arcpy.sa

 env.workspace = FD_addr&amp;nbsp; # DEM/DSM raster locations
 raster_list = arcpy.ListRasters("*", "ALL") # adds DEM/DSM raster
 size = len(raster_list) #### Make some exception here if != 2
 raster0 = arcpy.Raster(raster_list[0])
 raster1 = arcpy.Raster(raster_list[1])
 elevation = arcpy.sa.Con(raster1-raster0 &amp;gt;= 0, raster1-raster0,0)
 elevation.save("elevation") # saved in FD_addr
 &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:25:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737608#M57070</guid>
      <dc:creator>SAC_PhySAC_Phy</dc:creator>
      <dc:date>2021-12-12T07:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737609#M57071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not really sure how to see Arcmessages as I do everything in the command line, and not really familiar with the Arc command window/python tools.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How are you running this?&amp;nbsp; In the command window, or making a script tool or what?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If running in console window, after it runs, if you type:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
print elevation
print raster0
print raster1

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;do you get any results?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;also, can you create the elevation raster that you are after within arcmap using the tools?&amp;nbsp; I am wondering if it is creating an empty output, so is not saving it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would make sure that it is possible to do what you are trying using arcmap tools/model and get the desired output.&amp;nbsp; then work on the python code (export from the model builder and modify).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Might also look into the DEM format.&amp;nbsp; I have tried to use this in the past for certain tasks, and found that it does not support state plane coordinates.&amp;nbsp; Perhaps one of the input rasters is not supported or valid for this operation?&amp;nbsp; If you can do the raster calculations in ArcMap, then that would rule this out as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:25:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737609#M57071</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-12T07:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737610#M57072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I can create the elevation raster from the two rasters produced by the code by using the Raster Calculator.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried copying the code as a python snippet, but I read on the documentation for the Raster Calculator that it is only supported inside arcmap and will not work in a python script. The equivalent is supposedly how I'm trying to implement it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In Raster Calculator, I type in the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;elevation = Con("Surface_RAS"-"Ground_RAS"&amp;gt;=0,"Surface_RAS"-"Ground_RAS",0)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The python snippet is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.gp.RasterCalculator_sa("""elevation = Con("Surface_RAS"-"Ground_RAS"&amp;gt;=0,"Surface_RAS"-"Ground_RAS",0)""","C:/Summer_13/Geo.gdb/elevation")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(Surface_RAS and Ground_Ras are the two raster inputs that the code creates.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Works perfectly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm creating a new Python toolbox, and running the script as a tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DEM format? I'm not sure I know what you're referencing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Not really sure how to see Arcmessages as I do everything in the command line, and not really familiar with the Arc command window/python tools.&lt;BR /&gt;&lt;BR /&gt;How are you running this?&amp;nbsp; In the command window, or making a script tool or what?&lt;BR /&gt;&lt;BR /&gt;If running in console window, after it runs, if you type:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
print elevation
print raster0
print raster1

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;do you get any results?&lt;BR /&gt;&lt;BR /&gt;also, can you create the elevation raster that you are after within arcmap using the tools?&amp;nbsp; I am wondering if it is creating an empty output, so is not saving it.&lt;BR /&gt;&lt;BR /&gt;I would make sure that it is possible to do what you are trying using arcmap tools/model and get the desired output.&amp;nbsp; then work on the python code (export from the model builder and modify).&lt;BR /&gt;&lt;BR /&gt;Might also look into the DEM format.&amp;nbsp; I have tried to use this in the past for certain tasks, and found that it does not support state plane coordinates.&amp;nbsp; Perhaps one of the input rasters is not supported or valid for this operation?&amp;nbsp; If you can do the raster calculations in ArcMap, then that would rule this out as well.&lt;BR /&gt;&lt;BR /&gt;R_&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:25:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737610#M57072</guid>
      <dc:creator>SAC_PhySAC_Phy</dc:creator>
      <dc:date>2021-12-12T07:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737611#M57073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This works: &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.gp.RasterCalculator_sa("""elevation = Con("Surface_RAS"-"Ground_RAS"&amp;gt;=0,"Surface_RAS"-"Ground_RAS",0)""","C:/Summer_13/Geo.gdb/elevation")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But trying to edit it so that it takes the variables doesn't work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;DEM = arcpy.Raster(raster_list[0])
 DSM = arcpy.Raster(raster_list[1])
 expression = """elevation = Con({}-{}&amp;gt;=0,{}-{},0)""".format(DSM,DEM,DSM,DEM)
 raster_out = os.path.join(FD_addr,"elevation")
 arcpy.gp.RasterCalculator_sa(expression,raster_out)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Probably something is wrong with the expression variable. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have to look into figuring out how to convert the """....""" to make my expression&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:25:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737611#M57073</guid>
      <dc:creator>SAC_PhySAC_Phy</dc:creator>
      <dc:date>2021-12-12T07:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737612#M57074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; env.workspace = FD_addr&amp;nbsp; # DEM/DSM raster locations&lt;BR /&gt; raster_list = arcpy.ListRasters("*", "ALL") # adds DEM/DSM raster&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;is where I got the information that you were using a DEM (Digital Elevation Model by USGS).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I meant by using ArcMap tools, was not actually using the raster calculator, but the spatial analys "Con" tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I would do is open ArcMap, open the catalog window, right-click on Toolbox (or My Toolboxes) folder and choose "New" Model.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then, drag the sa.Con tool onto the model (if you can't find it, open the search window in ArcMap, select Tools, and type in Con, hit enter)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;double click the Con icon and fill in the parameters, click save and run the model.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you get the results you want, open the model, choose file, export python script.&amp;nbsp; This will give you a starting point, might have to clean up the syntax, etc. (i.e. Arc accepts "-" in path, python does not) and should give you an idea of how to code the "tool".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Noticed this uses the gp.Con_sa tool not the sa.Con tool.&amp;nbsp; however, it is 10.1 that dumps this code out, and don't see ANY documentation for it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 23:19:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737612#M57074</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-07-01T23:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Raster Calculator for Python Script</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737613#M57075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;What I meant by using ArcMap tools, was not actually using the raster calculator, but the spatial analys "Con" tool.&lt;BR /&gt;&lt;BR /&gt;What I would do is open ArcMap, open the catalog window, right-click on Toolbox (or My Toolboxes) folder and choose "New" Model.&lt;BR /&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Perfect, this worked!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I separated the process into two different models. I performed a Minus first, and used that as the input raster which had the conditional evaluated on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks so much for your help and patience!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 00:14:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculator-for-python-script/m-p/737613#M57075</guid>
      <dc:creator>SAC_PhySAC_Phy</dc:creator>
      <dc:date>2013-07-02T00:14:01Z</dc:date>
    </item>
  </channel>
</rss>

