# Simple iterate SetNull in ArcPy not working

For a large number of rasters, I need to define a pixel value less than zero as being Null and output the rasters. However, my simple SetNull loop (below) only processes the first raster in my list as Null, before stopping and not looping through the rest.

Triple commented ### is a dummy ExtractByMask function which I used to test the loop. When commented in, the ExtractByMask does loop successfully through all my rasters, indicating the loop itself seems okay. Can someone please advise, is there something specific I am not doing with SetNull please?

import arcpy, os, sys
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput = True

arcpy.env.workspace = "C:\\GIS\\in" # set up a folder containing rasters to clip
outws = "C:\\GIS\\out" # set up a folder to output clipped rasters to
#mask = "C:\\GIS\\dump\\pan.shp" # shapefile that defines clip

rasterlist = arcpy.ListRasters("*", "tif")
print(len(rasterlist))

for i in rasterlist:
print i
temp_nulled = SetNull(i,i,"VALUE < 0")

• print(len(rasterlist)) is printing more than 1? – BERA Jul 4 '18 at 13:28