I have a script which scans a directory and outputs basic raster data information such as the file name, format, number of bands, and etc. I need a way to make it so if the directory does not contain raster data (i.e., anything other than raster data), a message is displayed stating that the directory doesn't have the correct data type.
I know ArcPy has a Describe() function that I could use to determine the type of data in a folder, but am not sure how to implement it. This is what I have so far:
rasterList = arcpy.ListRasters("*", "ALL")
filesType = arcpy.DataType('RasterDataset') # Can use `DatasetType` as well.
# I've tested this function to describe
# raster data and ArcPy prints out
# 'RasterDataset', that is why I have it
# there in the brackets.
for name in rasterList:
if rasterList == filesType:
print ("\nFilename:"), name
else:
print ("This directory does not contain any raster data.")
Any suggestions?
len()function. – kaoscify Nov 19 '11 at 23:53