<?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: gp.Describe fails on second iteration of loop in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13697#M1073</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;...and I'll report the same problem! describe.NoDataValue for Raster Band Properties of unsigned 8 bit rasters fails as cited in this thread. (in python 2.5 and ArcGis 9.3) Mine are '.img' (ERDAS) format rather than grid format. Properties in ArcCatalog shows a NoData value of 255&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that it also fails if the raster doesn't have a NoData value set.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks to all for your posts. I've wasted enough time on this - your posts will save me wasting more time on it! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Disappointed that no-one from ESRI has answered your questions about whether its a bug, or inherent to these data types!&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;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Apr 2011 12:55:53 GMT</pubDate>
    <dc:creator>StephenPage</dc:creator>
    <dc:date>2011-04-05T12:55:53Z</dc:date>
    <item>
      <title>gp.Describe fails on second iteration of loop</title>
      <link>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13692#M1068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having some problems with the gp.Describe method in 9.3.1 and Python 2.5. If anyone can help I'd appreciate it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a folder called "Timeseries_All" which contains sub-folders called "1961", "1962" etc. Each of these folders contains 12 ESRI grids named "rain_year_month" (e.g. rain_1961_7 etc.). I want to get the no-data values for each of these rasters. My simple test code is as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Import modules
import arcgisscripting, os

# Create geoprocessor
gp = arcgisscripting.create(9.3)

# Set timeseries folder
tsFolder = "D:\Timeseries_All"

for year in range (1961, 1991):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for month in range(1, 13):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Path to raster
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path = os.path.join(tsFolder, str(year), 'rain_' + str(year) + '_' + str(month))

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Describe and return no-data value
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; noDatVal = gp.Describe(path).NoDataValue

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Print the result
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print noDatVal&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This works correctly for the first iteration of the loop and returns the no data value of rain_1961_1 (which is -32768). I get an error on the second iteration, though:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;gt;&amp;gt;&amp;gt; -32768
Traceback (most recent call last):
&amp;nbsp; File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript
&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__
&amp;nbsp; File "D:\James_S\Sarah_Tarland_Burn\Python\NoDataTest.py", line 14, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rnNoData = gp.Describe(rnMon).NoDataValue
RuntimeError: DescribeData: Get attribute NoDataValue does not exist&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The second dataset is not corrupt: I get the same message regardless of where I start in my data and all of my datasets appear to be fine. Anyone have any suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 14:17:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13692#M1068</guid>
      <dc:creator>jamessample</dc:creator>
      <dc:date>2010-12-08T14:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: gp.Describe fails on second iteration of loop</title>
      <link>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13693#M1069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;can't comment on the whole problem but this line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tsFolder = "D:\Timeseries_All"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;is going to cause problems since Python expects paths to be written as&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tsFolder = "D:\\Timeseries_All"&amp;nbsp;&amp;nbsp; or&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tsFolder = r"D:\Timeseries_All"&amp;nbsp;&amp;nbsp; or&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tsFolder = "D:/Timeseries_All"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print it out as well, since you may be missing the required \\ or / in the full path/filename&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 15:22:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13693#M1069</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2010-12-08T15:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: gp.Describe fails on second iteration of loop</title>
      <link>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13694#M1070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't know anything about rasters, but if it's not bad/empty data, then it must be the path.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd recommend printing the path with the value to make sure nothing is going wrong with the loop:&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;print path+" "+noDatVal&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 17:46:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13694#M1070</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2010-12-08T17:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: gp.Describe fails on second iteration of loop</title>
      <link>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13695#M1071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks to both of you for the replies.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd forgotten about using the double backslash in my path names - that's definitely a good idea. Luckily, in this case, os.path.join seems to have corrected my mistake for me: it inserted the double slashes into the path automatically and returned a properly formatted string. I've tried making the modifications that you suggest, but I still get the same problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have made some progress since yesterday though: the problem only occurs when I try to get the no data value of an 8-bit or 16-bit &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;unsigned &lt;/SPAN&gt;&lt;SPAN&gt;integer grid. It works for everything else. Am I missing something really obvious here? 8- or 16-bit unsigned integer grids can have no data values, right?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I right-click on one of these grids in ArcCatalog and choose "Properties", it tells me that the no data value is 0. If I try to get this value using gp.Describe(r"PathToGrid").NoDataValue I get this error:&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;DescribeData: Get attribute NoDataValue does not exist&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I do the same thing for a &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;signed &lt;/SPAN&gt;&lt;SPAN&gt;integer grid or a floating point grid the code runs fine and I get the same value as in the ArcCatalog "Properties" window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on this I've 'solved' my problem by adding a try/except block to my code so that if gp.Describe() works I get the correct value, otherwise I assume the no data value is 0. I'm still puzzled as to why it's failing though - is this some really basic "lore of rasters" that's so far eluded me, or is my system being weird?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again for the suggestions!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Dec 2010 08:26:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13695#M1071</guid>
      <dc:creator>jamessample</dc:creator>
      <dc:date>2010-12-09T08:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: gp.Describe fails on second iteration of loop</title>
      <link>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13696#M1072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have no resolution, but want to report the same problem.&amp;nbsp; describe.NoDataValue for Raster Band Properties of U16 rasters is not working properly in Python (python2.5 and ArcGis 9.3.1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to know if any one comes up with a resolution or if this is a bug.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Karen&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Dec 2010 20:05:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13696#M1072</guid>
      <dc:creator>KarenSchleeweis1</dc:creator>
      <dc:date>2010-12-14T20:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: gp.Describe fails on second iteration of loop</title>
      <link>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13697#M1073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;...and I'll report the same problem! describe.NoDataValue for Raster Band Properties of unsigned 8 bit rasters fails as cited in this thread. (in python 2.5 and ArcGis 9.3) Mine are '.img' (ERDAS) format rather than grid format. Properties in ArcCatalog shows a NoData value of 255&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that it also fails if the raster doesn't have a NoData value set.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks to all for your posts. I've wasted enough time on this - your posts will save me wasting more time on it! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Disappointed that no-one from ESRI has answered your questions about whether its a bug, or inherent to these data types!&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;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Apr 2011 12:55:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-describe-fails-on-second-iteration-of-loop/m-p/13697#M1073</guid>
      <dc:creator>StephenPage</dc:creator>
      <dc:date>2011-04-05T12:55:53Z</dc:date>
    </item>
  </channel>
</rss>

