0

I have a CSV file with a list of unique data sources extracted from an ArcGIS map document. I would like to list all ESRI GRID rasters that appear in the list.

One example is:

G:\GIS\Depts\Ex\PA\DB\Rasters\Grids\RDS\tzech_z

I understand the (arcgis.env.workspace) needs to be set first but I'm not sure how this can be done if there are multiple GRID files in different directories.

One code block I have tried results in a TypeError:

for pth in newList: # iterates through each unique path
  pthDir = os.path.dirname(pth)
  arcpy.env.workspace = pthDir
  esriGridList = arcpy.ListRasters("*", "GRID")
  print esriGridList

Produces the error:

TypeError: 'NoneType' object is not iterable

  • you need to check if the folder location exist. if arcpy.Exists(pthDir): then assign workspace, etc. – fatih_dur Sep 6 '18 at 14:01
  • Also pthDir = os.path.dirname(pth)Dir should have thrown an exception. – fatih_dur Sep 6 '18 at 14:07
  • Typo. Now corrected. – Howeitzer Sep 7 '18 at 6:14
  • So newList is a python list of unique paths which include feature classes, ESRI GRIDS, images (.jpg, .png), shapefiles. Some in the same directory, some are in different. I'd rather not have to set the workspace of every directory to check for ESRI GRIDS but this might be the only solution. – Howeitzer Sep 7 '18 at 6:35
  • which line does produce this error? If it is not here please add this to your post, since I presumed the issue was setting the workspace but if there is no GRID in the folder, esriGridList gets None and if you try to process this somewhere else, this may cause issues! – fatih_dur Sep 7 '18 at 6:38
1

The error is referring to a NoneType object (None) being used as though it was an iterable object. The only instance of using an iterable that I can see (in the portion of code that you posted) is the newList variable in the for loop.

This implies that your newList variable has a value of None. (Or possibly that there is another NULL object elsewhere in the script that it being used as an iterable).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.