I am trying to combine two different raster files using a loop, with the following script.
import arcpy
import os
thectr = 0
ws = arcpy.env.workspace = r'D:\BRB Snow Cover\Sample\TerAqua'
Terra_Rasters = arcpy.ListRasters("MOD*")
Aqua_Rasters = arcpy.ListRasters("MYD*")
output = "D:\\BRB Snow Cover\\Sample\\output""\\"+ str(thectr)+'.tif'
matches = 0
for item1 in Terra_Rasters:
for item2 in Aqua_Rasters:
print item1
print item2
if item1.endswith(item2[32:51]):
print "Match"
arcpy.gp.Con_sa(item1,item2,output,item1,"\"Value\" =8")
else:
print "No"
matches = matches+1
I need to use a loop for the output files name, I faced the following error.
Runtime error Traceback (most recent call last): File "", line 7, in File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\geoprocessing_base.py", line 510, in return lambda *args: val(*gp_fixargs(args, True)) ExecuteError: ERROR 000872: Output raster: Dataset D:\BRB Snow Cover\Sample\output0.tif already exists and cannot be overwritten since the Overwrite existing datasets option is disabled.