I want to replace the even pixel values of a raster from 1 and rest with 0. Since, I have 100+ raster files therefore, I am calling filenames in loop.
I copied the python snippet after applying
con operation on a single file that worked fine. However, it fails in the script and shows error as,
NameError: name 'fin' is not defined Failed to execute (RasterCalculator).
fin is the variable name.
import arcpy Path = "Path/to/folder/" for year in range(2010,2016): for day in range(1,369,8): fin = Path + 'Raster'+ str(year) + "_D" + str(day).zfill(3) + ".tif" out = Path + 'Processed_Raster'+ str(year) + "_D" + str(day).zfill(3) + ".tif" arcpy.gp.RasterCalculator_sa("""Con(Mod(fin,2) == 0,1,0)""", out)
How to resolve this error?