gp.Describe fails on second iteration of loop

Discussion created by jamessample on Dec 8, 2010
Latest reply on Apr 5, 2011 by steveattt
Hi all,

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.

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:

# 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):
    for month in range(1, 13):
        # Path to raster
        path = os.path.join(tsFolder, str(year), 'rain_' + str(year) + '_' + str(month))

        # Describe and return no-data value
        noDatVal = gp.Describe(path).NoDataValue

        # Print the result
        print noDatVal

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:

>>> -32768
Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript
    exec codeObject in __main__.__dict__
  File "D:\James_S\Sarah_Tarland_Burn\Python\NoDataTest.py", line 14, in <module>
    rnNoData = gp.Describe(rnMon).NoDataValue
RuntimeError: DescribeData: Get attribute NoDataValue does not exist

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?