<?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 calculation in python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423464#M33260</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Luke,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good Day!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried the changes that you suggested but get the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__&lt;BR /&gt;&amp;nbsp; File "E:\Python_scripts\ArcGIS\AWD_pct_v2.py", line 25, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = Raster(rast) / rastVal[rast] * 100 # the equation that I want to execute...i.e., (raster1/11.2)*100&lt;BR /&gt;RuntimeError: ERROR 000732: Input Raster: Dataset RE_suitable_dek004 does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the portion of the script that I used:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for rast in rastVal: # Iterate to all raster in the directory
&amp;nbsp;&amp;nbsp; outRaster = os.path.join(raster_ow, os.path.basename(rast)) # output path and filename of my raster
&amp;nbsp;&amp;nbsp; if rast in rastVal: # iterate my raster if in the dictionary
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = Raster(rast) / rastVal[rast] * 100 # the equation that I want to execute...i.e., (raster1/11.2)*100
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster.save(outRaster + "pct") # output raster with pct (percentage) suffix
&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "ERROR: No matching entry in raster value look up dictionary!"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to change the portion of the script to arcpy.Raster(rast) but also throws the same error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for rast in rastVal: # Iterate to all raster in the directory
&amp;nbsp;&amp;nbsp; outRaster = os.path.join(raster_ow, os.path.basename(rast)) # output path and filename of my raster
&amp;nbsp;&amp;nbsp; if rast in rastVal: # iterate my raster if in the dictionary
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = &lt;STRONG&gt;arcpy.Raster(rast)&lt;/STRONG&gt; / rastVal[rast] * 100 # the equation that I want to execute...i.e., (raster1/11.2)*100
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster.save(outRaster + "pct") # output raster with pct (percentage) suffix
&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "ERROR: No matching entry in raster value look up dictionary!"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__&lt;BR /&gt;&amp;nbsp; File "E:\Python_scripts\ArcGIS\AWD_pct_v2.py", line 25, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = arcpy.Raster(rast) / rastVal[rast] * 100 # the equation that I want to execute...i.e., (raster1/11.2)*100&lt;BR /&gt;RuntimeError: ERROR 000732: Input Raster: Dataset RE_suitable_dek004 does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have problem with my list of rasters, but I am at lost how to deal with the error. I am not sure if the problem has something to do with my loop statement.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Leo&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 19:07:41 GMT</pubDate>
    <dc:creator>Leo_KrisPalao</dc:creator>
    <dc:date>2021-12-11T19:07:41Z</dc:date>
    <item>
      <title>raster calculation in python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423460#M33256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi ArcGIS Python experts,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am working on automating my workflow for a project.&amp;nbsp; For now I am testing my script for only five rasters, then scale-up my analysis if the script will work okay. Once the code is already running, I will incorporate it in another code that I am setting up. I want to get the percentage of each cell using raster calculator. I got the initial code from another thread.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The equation that I am trying to execute is (raster1) / (a specified value) * 100 # computing for percentage&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The workflow looks like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RE_suitable_dek001 / 11.2 * 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RE_suitable_dek002 / 14.9 * 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RE_suitable_dek003 / 9.4 * 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RE_suitable_dek004 / 10.4 * 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RE_suitable_dek005 / 12.4 * 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Some details:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Software: ArcGIS 10.2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;OS: Windows 7 Prof 64 bit&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Python console: PythonWin&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os, sys from arcpy import env from arcpy.sa import * arcpy.env.overwriteOutput = True arcpy.CheckOutExtension("Spatial") arcpy.env.workspace = r'E:\Test_awd\awd_pct'&amp;nbsp; # Raster workspace raster_ws = r'E:\Test_awd\awd_pct'&amp;nbsp; # Getting the list of raster dataset arcpy.env.workspace = raster_ws rasters = [os.path.join(raster_ws, r) for r in arcpy.ListRasters()]&amp;nbsp; #Output workspace raster_ow = r'E:\Test_awd\awd_pct'&amp;nbsp; # Get dictionary (raster1:value, ..., raster5:value) rastVal = {"RE_suitable_dek001":11.2,"RE_suitable_dek002":14.9, "RE_suitable_dek003":9.4, "RE_suitable_dek004":10.4, "RE_suitable_dek005":12.4}&amp;nbsp; # Raster map algebra for rast in rastVal: # Iterate to all raster in the directory &amp;nbsp;&amp;nbsp; outRaster = os.path.join(raster_ow, os.path.basename(rast)) # output path and filename of my raster &amp;nbsp;&amp;nbsp; if rast in rastVal: # iterate my raster if in the dictionary &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = rasters / rastVal[rast] * 100 # the equation that I want to execute...(raster1/11.2)*100 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster.save(outRaster + "pct") # output raster with pct (percentage) suffix &amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "ERROR: No matching entry in raster value look up dictionary!"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the error that I am getting:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "E:\Python_scripts\ArcGIS\AWD_pct_v2.py", line 25, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = rasters / rastVal[rast] * 100 # the equation that I want to execute...(raster1/11.2)*100&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TypeError: unsupported operand type(s) for /: 'list' and 'float'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Leo&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2014 01:19:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423460#M33256</guid>
      <dc:creator>Leo_KrisPalao</dc:creator>
      <dc:date>2014-06-11T01:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: raster calculation in python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423461#M33257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Leo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From the error code, its pretty clear what the problem is in your code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Line 25 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outRaster = rasters / rastVal[rast] * 100 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TypeError: unsupported operand type(s) for /: 'list' and 'float'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From your code I'm not sure exactly what you are trying to do, but you are dividing a list by a float and that throws a type error, since rasters = [os.path.join(raster_ws, r) for r in arcpy.ListRasters()], so your variable rasters is a list.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Depending on what you are trying to do, you will probably need to loop through your rasters list to get the actual raster out of it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you could make it a bit more clear what you are trying to do, it would be a little easier to help you out, but thats why its throwing an error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: Read your post a bit more carefully, if you just need the first raster from your rasters list, use an index, otherwise, you will need to loop through them.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2014 12:14:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423461#M33257</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-06-11T12:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: raster calculation in python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423462#M33258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Ian,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your reply and my apologies if my question is not clear.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I really want is to divide each of my rasters (rasters in my folder) by a specific value, then multiply it by 100.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;Raster01 / 11.2 * 100&lt;BR /&gt;Raster02 / 14.9 * 100&lt;BR /&gt;Raster03 / 9.4 * 100&lt;BR /&gt;Raster04 / 10.4 * 100&lt;BR /&gt;Raster05 / 12.4 * 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is why I created a list of my rasters so I can loop to all of my rasters. &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;rasters = [os.path.join(raster_ws, r) for r in arcpy.ListRasters()]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I created a dictionary to assign a specific value for each raster. For instance Raster01 should be linked to a value 11.2. The value 11.2 will be used later as a denominator for Raster01.&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;rastVal = {"RE_suitable_dek001":11.2,"RE_suitable_dek002":14.9, "RE_suitable_dek003":9.4, "RE_suitable_dek004":9.4, "RE_suitable_dek005":9.4}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Leo&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jun 2014 01:22:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423462#M33258</guid>
      <dc:creator>Leo_KrisPalao</dc:creator>
      <dc:date>2014-06-13T01:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: raster calculation in python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423463#M33259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You're trying to use a list in your expression instead of a Raster object. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Change this: outRaster = rasters / rastVal[rast] * 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To this: outRaster = Raster(rast) / rastVal[rast] * 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//018z00000051000000"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//018z00000051000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jun 2014 09:52:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423463#M33259</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2014-06-16T09:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: raster calculation in python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423464#M33260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Luke,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good Day!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried the changes that you suggested but get the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__&lt;BR /&gt;&amp;nbsp; File "E:\Python_scripts\ArcGIS\AWD_pct_v2.py", line 25, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = Raster(rast) / rastVal[rast] * 100 # the equation that I want to execute...i.e., (raster1/11.2)*100&lt;BR /&gt;RuntimeError: ERROR 000732: Input Raster: Dataset RE_suitable_dek004 does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the portion of the script that I used:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for rast in rastVal: # Iterate to all raster in the directory
&amp;nbsp;&amp;nbsp; outRaster = os.path.join(raster_ow, os.path.basename(rast)) # output path and filename of my raster
&amp;nbsp;&amp;nbsp; if rast in rastVal: # iterate my raster if in the dictionary
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = Raster(rast) / rastVal[rast] * 100 # the equation that I want to execute...i.e., (raster1/11.2)*100
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster.save(outRaster + "pct") # output raster with pct (percentage) suffix
&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "ERROR: No matching entry in raster value look up dictionary!"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to change the portion of the script to arcpy.Raster(rast) but also throws the same error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for rast in rastVal: # Iterate to all raster in the directory
&amp;nbsp;&amp;nbsp; outRaster = os.path.join(raster_ow, os.path.basename(rast)) # output path and filename of my raster
&amp;nbsp;&amp;nbsp; if rast in rastVal: # iterate my raster if in the dictionary
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = &lt;STRONG&gt;arcpy.Raster(rast)&lt;/STRONG&gt; / rastVal[rast] * 100 # the equation that I want to execute...i.e., (raster1/11.2)*100
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster.save(outRaster + "pct") # output raster with pct (percentage) suffix
&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "ERROR: No matching entry in raster value look up dictionary!"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__&lt;BR /&gt;&amp;nbsp; File "E:\Python_scripts\ArcGIS\AWD_pct_v2.py", line 25, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outRaster = arcpy.Raster(rast) / rastVal[rast] * 100 # the equation that I want to execute...i.e., (raster1/11.2)*100&lt;BR /&gt;RuntimeError: ERROR 000732: Input Raster: Dataset RE_suitable_dek004 does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have problem with my list of rasters, but I am at lost how to deal with the error. I am not sure if the problem has something to do with my loop statement.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Leo&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:07:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423464#M33260</guid>
      <dc:creator>Leo_KrisPalao</dc:creator>
      <dc:date>2021-12-11T19:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: raster calculation in python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423465#M33261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You either need to set the workspace to the location of the rasters (arcpy.env.workspace = path to rasters) or pass the full pathname when creating the Raster object i.e Raster(os.path.join(path to raster, rasterfilename))&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jun 2014 18:23:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423465#M33261</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2014-06-18T18:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: raster calculation in python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423466#M33262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Change your for loop from&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;for rast in rastVal:&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;for rast in rasters:&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then this should work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;outRaster = Raster(rast) / rastVal[rast] * 100&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jun 2014 18:32:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423466#M33262</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2014-06-18T18:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: raster calculation in python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423467#M33263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Luke, I followed your suggestion and I was able to run the script. Aside from changing in &lt;/SPAN&gt;&lt;STRONG&gt;rastVal &lt;/STRONG&gt;&lt;SPAN&gt;to &lt;/SPAN&gt;&lt;STRONG&gt;rasters&lt;/STRONG&gt;&lt;SPAN&gt; in my loop statement, I also change the name of my rasters to the fullpath:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;RE_suitable_dek001:9.4&lt;/STRONG&gt;&lt;SPAN&gt; to &lt;/SPAN&gt;&lt;STRONG&gt;r'Fullpath\RE_suitable_dek001:9.4&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also read this method in your post but I think you have already removed it in the thread.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Leo&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Jun 2014 23:59:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423467#M33263</guid>
      <dc:creator>Leo_KrisPalao</dc:creator>
      <dc:date>2014-06-22T23:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: raster calculation in python</title>
      <link>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423468#M33264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I also change the name of my rasters to the fullpath:&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;RE_suitable_dek001:9.4&lt;/STRONG&gt; to &lt;STRONG&gt;r'Fullpath\RE_suitable_dek001:9.4&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;I also read this method in your post but I think you have already removed it in the thread.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;I removed that post as I reread your original post and saw you were already using the full path in your script:&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;rasters = [os.path.join(raster_ws, r) for r in arcpy.ListRasters()]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I forgot that you didn't use the full path in your rastVal lookup dictionary.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please click the big check mark next to one of the above answers to indicate they answered your question.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2014 00:36:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/raster-calculation-in-python/m-p/423468#M33264</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2014-06-23T00:36:20Z</dc:date>
    </item>
  </channel>
</rss>

