I am trying to extract a raster through a particular shapefile.
import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
env.overwriteOutput = True
#Set the current workspace
env.workspace = ("C:\thesis\Forests Only Percent Treecover\2003 BSWM Forest")
env.nodata = "MINIMUM"
env.compression = "LZ77"
#This is for extracting the forest areas of hansen percent treecover
for raster in arcpy.ListRasters("*0E.tif", "TIFF"):
print raster #checking the presence of raster
outputRasterExtractbyMask = ExtractByMask(raster, "NAMRIA.shp")
outputRasterExtractbyMask_Name = "forests_only"+raster
outputRasterExtractbyMask.save(outputRasterExtractbyMask_Name)
print "Finish"
As I print the raster in arcpy.ListRasters to check the presence of raster, this error shows up:
Traceback (most recent call last):
File "C:\Users\brentiebark\Dropbox\Python Scripts and mxds\extractbymask.py", line 14, in <module>
for raster in arcpy.ListRasters("*0E.tif", "TIFF"):
TypeError: 'NoneType' object is not iterable
I double checked the directory, and my files are really there. Is there something wrong with my code?