I am currently learning arcgis and python.
The problem includes looping through 2 folders (with rasters of same filename) and performing raster calculation on each raster pair. Below is my code:
import arcpy, os, glob
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
ws1 = "E:\clip_qx"
ws2 = "E:\clip_qy"
outws = "E:\result"
rasterlist = arcpy.ListRasters()
for r in ws1:
r1 = arcpy.sa.Raster(r)
r2 = arcpy.sa.Raster(os.path.join(ws2, basename))
result = sqrt ( r1^2 + r2^2 )
outname = basename
result.save(os.path.join(outws, outname))
However, I am getting an error. It seems that the rasters were not read.
RuntimeError: ERROR 000732: Input Raster: Dataset E does not exist or is not supported.
w1 = r"E:\clip_qx"
. Python interprets the backslash in a string as an indicator of a special character. – Bjorn Aug 2 '17 at 16:48basename
isn't defined. You probably meanr
(the file name). – Emil Brundage Aug 2 '17 at 17:46