Skip to main content
tyops; removed helpme
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

Finding raster files innin a directory that contain noData pixels/cells ... ArcGIS and Python

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 tiffTIFF file names into a list. By inspection most of the tiffTIFF 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 lnowknow there are no data values

Can anyone offer some advice pleaseWhat 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')

Finding raster files inn a directory that contain noData pixels/cells ... ArcGIS and Python

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 lnow there are no data values

Can anyone offer some advice please

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')

Finding raster files in a directory that contain noData pixels/cells ... ArcGIS and Python

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')

edited title
Link
TrevP
  • 611
  • 5
  • 13

Finding raster files inn a directory that contain noData pixels/cells ... ArcGIS and Python

Source Link
TrevP
  • 611
  • 5
  • 13

Finding raster files inn a directory that contain noData pixels/cells

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 lnow there are no data values

Can anyone offer some advice please

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')