<?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: TypeError Expecting a raster, but it IS a raster? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128393#M9972</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Stacy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;They are defined. This is condensed. I'm recovering from a cold, so not as crafty as I think I am right now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll try to edit my post.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I originally tried running this while saving all my intermediate raster layers. The same error occurs. Of course without the intermediate rasters saved, I can't just comment out and continue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Working with rasters in Arcpy seems to be rought with frustration. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for looking.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;RT&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Feb 2012 21:52:24 GMT</pubDate>
    <dc:creator>RichardThurau</dc:creator>
    <dc:date>2012-02-16T21:52:24Z</dc:date>
    <item>
      <title>TypeError Expecting a raster, but it IS a raster?</title>
      <link>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128391#M9970</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;SPAN&gt;I am trying to use python to run a few consecutive reclassifications, but the script crashes between processes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy #import os from arcpy.sa import * from arcpy import env arcpy.CheckOutExtension("Spatial") arcpy.env.overwriteOutput = True&amp;nbsp; EOSD = "X:\\EOSD_for100" MunRas2 = "X:\\MunRas_East_100" WScom1_rc = "X:\\area_e4buf_comb1_RC.img"#WScom1[0:-4] + "_RC.img" WScom2 = WScom1_rc[0:-4] + "_mun_com.img" WScom2_rc = WScom2[0:-4] + "_RC.img" WScom3 = WScom2_rc[0:-4] + "_eosd_com.img" WScom3_rc = WScom3[0:-4] + "_RC.img"&amp;nbsp; WScom2 = (Raster(WScom1_rc) + Raster(MunRas2)) WScom2_rc = Reclassify(WScom2, "Value", RemapValue([[0, "NODATA"], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [9, 9], [100, "NODATA"], [101, 1], [102, 2], [103, 7], [104, 4], [105, 5], [106, 6], [109, 9]]))&amp;nbsp; WScom3 = (Raster(WScom2_rc) + Raster(EOSD)) WScom3_rc = Reclassify(WScom3, "Value", RemapValue([[0, "NODATA"], [1, 1], [2, 2], [3,3], [4, 4], [5,5],[6, 6], [7, 7], [9, 9], [101, 11], [102, 12], [103, 13], [104, 14], [105, 15], [106, 16], [107, 17], [109, 19]]))&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, between WScom2_rc and WScom3, the code crashes with the following error: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WScom3 = (Raster(WScom2_rc) + Raster(EOSD))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TypeError: expected a raster or layer name&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I comment out the first set of code and run the second, it processes without issue. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone see something I'm doing wrong? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 20:58:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128391#M9970</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2012-02-16T20:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError Expecting a raster, but it IS a raster?</title>
      <link>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128392#M9971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Richard,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is that the code you are actually using?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the lines:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE&gt;WScom2 = (Raster(WScom1_rc) + Raster(MunRas2))&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE&gt;WScom3 = (Raster(WScom2_rc) + Raster(EOSD))&lt;/PRE&gt;&lt;BR /&gt;&lt;STRONG&gt;MunRas2 &lt;/STRONG&gt;&lt;SPAN&gt;and &lt;/SPAN&gt;&lt;STRONG&gt;EOSD &lt;/STRONG&gt;&lt;SPAN&gt;have never been defined, but that should cause a &lt;/SPAN&gt;&lt;STRONG&gt;NameError&lt;/STRONG&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 21:37:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128392#M9971</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2012-02-16T21:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError Expecting a raster, but it IS a raster?</title>
      <link>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128393#M9972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Stacy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;They are defined. This is condensed. I'm recovering from a cold, so not as crafty as I think I am right now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll try to edit my post.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I originally tried running this while saving all my intermediate raster layers. The same error occurs. Of course without the intermediate rasters saved, I can't just comment out and continue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Working with rasters in Arcpy seems to be rought with frustration. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for looking.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;RT&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 21:52:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128393#M9972</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2012-02-16T21:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError Expecting a raster, but it IS a raster?</title>
      <link>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128394#M9973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Richard,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the output of &lt;/SPAN&gt;&lt;STRONG&gt;Reclassify()&lt;/STRONG&gt;&lt;SPAN&gt; is a raster object. The &lt;/SPAN&gt;&lt;STRONG&gt;Raster() &lt;/STRONG&gt;&lt;SPAN&gt;function converts a path or layer name into a raster object, but you already have raster objects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The raster addition will accept either a path or a raster object, so where you currently have this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE&gt;WScom3 = (Raster(WScom2_rc) + Raster(EOSD))&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;it fails as &lt;/SPAN&gt;&lt;STRONG&gt;WScom2_rc&lt;/STRONG&gt;&lt;SPAN&gt; is already a raster object - you cannot put it into &lt;/SPAN&gt;&lt;STRONG&gt;Raster()&lt;/STRONG&gt;&lt;SPAN&gt;.. However, this should work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE&gt;WScom3 = WScom2_rc + Raster(EOSD)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;and so should this (although in my opinion it should not):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE&gt;WScom3 = WScom2_rc + EOSD&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When you commented out part of your code, you were just adding the rasters by path so it worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, you shouldn't put unnecessary brackets around things (i.e. when just adding two things together) as brackets can have a special meaning - I took them out for the bottom two snippets above.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Stacy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 22:47:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128394#M9973</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2012-02-16T22:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError Expecting a raster, but it IS a raster?</title>
      <link>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128395#M9974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Stacy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I see, that makes sense. Look forward to trying it in the morning.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for taking the time to respond.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 07:18:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128395#M9974</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2012-02-17T07:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError Expecting a raster, but it IS a raster?</title>
      <link>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128396#M9975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As I suspected, code works very well now. I'm unable to find the example again, but I'm pretty sure the esri example has the double parentheses. Unfortunately, or for whatever it's worth, those examples and these forums have provided the bulk of my python knowledge.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rich&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 20:32:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/typeerror-expecting-a-raster-but-it-is-a-raster/m-p/128396#M9975</guid>
      <dc:creator>RichardThurau</dc:creator>
      <dc:date>2012-02-17T20:32:27Z</dc:date>
    </item>
  </channel>
</rss>

