<?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' object is not iterable in ArcGIS Spatial Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-object-is-not-iterable/m-p/236453#M3306</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Subhasis, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I notice you have 5 separate threads on more or less the same topic:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/people/sean.woznicki/content" title="https://community.esri.com/people/sean.woznicki/content"&gt;Inception Woznicki&lt;/A&gt;‌ (just look at the content)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a few recommendations:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Concentrate on this topic: &lt;A href="https://community.esri.com/thread/104750"&gt;loop for value and counts in raster attribute&lt;/A&gt; is has the most answers.&lt;/LI&gt;&lt;LI&gt;If there are helpful comments mark them as helpful, it will help other user to find useful content faster&lt;/LI&gt;&lt;LI&gt;If a question was answered mark the thread as answered at the right comment, this also helps the community to find useful content, and avoids people to invest their time in your question, if your question was already solved.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Jul 2014 02:46:38 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2014-07-28T02:46:38Z</dc:date>
    <item>
      <title>Raster' object is not iterable</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-object-is-not-iterable/m-p/236452#M3305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I 'm trying to calculate the percentage of cell counts in new raster and the new raster is created from an old raster based on the Value &amp;gt; 14. In my code, 1st for loop is for original raster and keeping the value and count fields in a dictionary. Then, creating new raster using Value &amp;gt; 14. The 2nd for loop is for the new raster and keeping its value and counts of in a new dictionary and finally calculating the percentage. &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I am getting an error on the 2nd for loop. The error says " 'Raster' object is not iterable". Anybody has any suggestion. Thank you for your help!&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import arcpy, os&lt;/P&gt;&lt;P&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;from arcpy.sa import *&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#To overwrite output&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#Set environment settings&lt;/P&gt;&lt;P&gt;env.workspace = "C:/Subhasis/Test/Neshanic_Python"&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;outws="C:/Subhasis/Test/Neshanic_Python/extract"&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#checkout ArcGIS spatial analyst extension license&lt;/P&gt;&lt;P&gt;arcpy.CheckOutExtension("Spatial")&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# set local variable&lt;/P&gt;&lt;P&gt;inraster = ["01367620-r-r"] &lt;/P&gt;&lt;P&gt;for i in inraster:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; flds = ("VALUE", "COUNT")&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dct = {row[0]:row[1] for row in arcpy.da.SearchCursor(i, flds)}&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sumcnt = sum(dct.values())&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newraster = ExtractByAttributes(str(i), "VALUE&amp;gt;=14")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for j in newraster:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flds1 = ("VALUE", "COUNT")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dct1 = {row[0]:row[1] for row in arcpy.da.SearchCursor(j, flds)}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sumcnt1 = sum(dct1.values())&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; percentage=(sumcnt/sumcnt1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print percentage&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jul 2014 15:34:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-object-is-not-iterable/m-p/236452#M3305</guid>
      <dc:creator>InceptionWoznicki</dc:creator>
      <dc:date>2014-07-23T15:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Raster' object is not iterable</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-object-is-not-iterable/m-p/236453#M3306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Subhasis, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I notice you have 5 separate threads on more or less the same topic:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/people/sean.woznicki/content" title="https://community.esri.com/people/sean.woznicki/content"&gt;Inception Woznicki&lt;/A&gt;‌ (just look at the content)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a few recommendations:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Concentrate on this topic: &lt;A href="https://community.esri.com/thread/104750"&gt;loop for value and counts in raster attribute&lt;/A&gt; is has the most answers.&lt;/LI&gt;&lt;LI&gt;If there are helpful comments mark them as helpful, it will help other user to find useful content faster&lt;/LI&gt;&lt;LI&gt;If a question was answered mark the thread as answered at the right comment, this also helps the community to find useful content, and avoids people to invest their time in your question, if your question was already solved.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jul 2014 02:46:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-object-is-not-iterable/m-p/236453#M3306</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-07-28T02:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Raster' object is not iterable</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-object-is-not-iterable/m-p/236454#M3307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xander,&lt;/P&gt;&lt;P&gt;This is a pretty good suggestion. I marked it as answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Subhasis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jul 2014 12:59:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/raster-object-is-not-iterable/m-p/236454#M3307</guid>
      <dc:creator>InceptionWoznicki</dc:creator>
      <dc:date>2014-07-28T12:59:24Z</dc:date>
    </item>
  </channel>
</rss>

