I am trying to find a way of looping through Rasters in a directory, (a collection of individual tiff images in a folder) and selecting by name only those rasters that contain noData values and passing those TIFF file names into a list. By inspection most of the TIFF files do not have noData values in them. However a number do and I would like to be able to achieve this programmatically. I am trying to do this using arcpy / ArcGIS tools and modules
My code so far is below, but it is not picking out the rasters where I know there are no data values
What is wrong?
import arcpy
arcpy.env.workspace = r'C:\myRasters\...'
rasterList = arcpy.ListRasters()
incompleteRasters = []
for raster in rasterList:
rasterObj = arcpy.Raster(raster)
print(rasterObj.name)
if rasterObj.noDataValue == True:
incompleteRasters.append(rasterObj)
print("NoData Value: %s \n" %noData, "in ", rasterObj.name)
else:
print("all ok")
print('All', len(rasterList), 'tifs have been checked')