I'm a rookie in python programming.I want to do map algebra for multiple rasters but these rasters are in different folders. Here's the code ive created so far:
#Importing modulesimport arcpyfrom arcpy import envfrom arcpy.sa import *#Files namename1 = "BR_CRU_PRE"name2 = "BR_CRU_ETP"#Workspacepath = r"C:\Users\Ibytee\Documents\FUNCEME\ParaGiullian\Dados_ArcGIS\PRE_ETP"env.workspace = path#Checking for extensionarcpy.CheckOutExtension("Spatial")#Creating raster listsfolders = ["PRE","ETP"]env.workspace = path +"\\"+ folders[0]a = arcpy.ListRasters(name1+"*", "TIF")env.workspace = path +"\\"+ folders[1]b = arcpy.ListRasters(name2+"*", "TIF")#Executing the loopfor p, etp in zip(a, b): print p outRaster = Raster(p) - Raster(etp) outRaster.save(path+"\\PRE_ETP_SUB\\"+"sub_"+name1+"_%s" %etp) print "sub_"+name1+"_%s" %etpThis script seems to be accessing the right folders and creating the raster list, but when it comes the time to do the map algebra, looks like the script searches the rasters in the wrong folder. Here's the error I get:
C:\Python27\ArcGIS10.1\python.exe C:/Users/Ibytee/Documents/eclipse_workspace/Scripts/teste.pyBR_CRU_PRE_ANO1971.tifTraceback (most recent call last): File "C:/Users/Ibytee/Documents/eclipse_workspace/Scripts/teste.py", line 24, in outRaster = Raster(p) - Raster(etp)RuntimeError: ERROR 000732: Input Raster: Dataset BR_CRU_PRE_ANO1971.tif does not exist or is not supportedProcess finished with exit code 1
أكثر...
#Importing modulesimport arcpyfrom arcpy import envfrom arcpy.sa import *#Files namename1 = "BR_CRU_PRE"name2 = "BR_CRU_ETP"#Workspacepath = r"C:\Users\Ibytee\Documents\FUNCEME\ParaGiullian\Dados_ArcGIS\PRE_ETP"env.workspace = path#Checking for extensionarcpy.CheckOutExtension("Spatial")#Creating raster listsfolders = ["PRE","ETP"]env.workspace = path +"\\"+ folders[0]a = arcpy.ListRasters(name1+"*", "TIF")env.workspace = path +"\\"+ folders[1]b = arcpy.ListRasters(name2+"*", "TIF")#Executing the loopfor p, etp in zip(a, b): print p outRaster = Raster(p) - Raster(etp) outRaster.save(path+"\\PRE_ETP_SUB\\"+"sub_"+name1+"_%s" %etp) print "sub_"+name1+"_%s" %etpThis script seems to be accessing the right folders and creating the raster list, but when it comes the time to do the map algebra, looks like the script searches the rasters in the wrong folder. Here's the error I get:
C:\Python27\ArcGIS10.1\python.exe C:/Users/Ibytee/Documents/eclipse_workspace/Scripts/teste.pyBR_CRU_PRE_ANO1971.tifTraceback (most recent call last): File "C:/Users/Ibytee/Documents/eclipse_workspace/Scripts/teste.py", line 24, in outRaster = Raster(p) - Raster(etp)RuntimeError: ERROR 000732: Input Raster: Dataset BR_CRU_PRE_ANO1971.tif does not exist or is not supportedProcess finished with exit code 1
أكثر...