I am doing the work of change all null pixels to a value of -1 in the raster file X with raster calculator by using following syntax:


However, I need to do the same work on >200 raster files. Is there any other method so that I can do these works simply?


ModelBuilder is all that you need.

You have to loop through your layers with iterator (Iterate Rasters).


You can automate this using Python and the Con (Spatial Analyst) function.

import arcpy
from arcpy.sa import *
arcpy.CheckOutExtension = "Spatial"

arcpy.env.workspace = "C:/temp/data"
outws = "C:/temp/out"

rasters = arcpy.ListRasters()

for r in rasters:
    inras = Raster(r)
    outCon = Con(IsNull(inRas), -1, inRas)
    outCon.save(os.path.join(outws, r))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.