Hello all,
I want to do a raster calculation as done here: https://gis.stackexchange.com/questions/332925/looping-through-two-raster-folders-to-perform-raster-calculation and here: https://gis.stackexchange.com/questions/333082/looping-through-two-raster-folders-to-perform-raster-calculation-gives-error-000
It is more or less running correctly, but the output is written into the first env.workspace or second env.workspace. I simply cannot get the output rasters into my dedicated output directory.
Any clues?
Here my code snipped:
import arcpy
from arcpy import env
from arcpy.sa import *#Spatial Analyst module
import os
from datetime import datetime
import subprocess
import glob
arcpy.env.overwriteOutput = True
arcpy.env.matchMultidimensionalVariable = False
arcpy.CheckOutExtension("Spatial")
#-----------------------------
# Divide LPAWC*100 by LAPWC
# get first set of rasters
LPAWC = r"K:\6202_Klimawandel_Folgen_Anpassung\620203_Werkbank\mGROWA\WHM_Klimaatlas_Neuentwicklungen\LPAWCDate.gdb" #'source 1'
arcpy.env.workspace = LPAWC
rasters_LPAWC = arcpy.ListRasters()
rasters_LPAWC = [os.path.join(LPAWC, r) for r in rasters_LPAWC] # necessary for zip, but permits folder2 to get to work...
# get second set of rasters
LPAWFC = r"K:\6202_Klimawandel_Folgen_Anpassung\620203_Werkbank\mGROWA\WHM_Klimaatlas_Neuentwicklungen\LPAWFC.gdb" #'source 2'
arcpy.env.workspace = LPAWFC
rasters_LPAWFC = arcpy.ListRasters()
rasters_LPAWFC = [os.path.join(LPAWFC, rs) for rs in rasters_LPAWFC] # necessary for zip, but permits folder2 to get to work...
# folder path2
folder2 = r"K:\6202_Klimawandel_Folgen_Anpassung\620203_Werkbank\mGROWA\WHM_Klimaatlas_Neuentwicklungen\LPWCfinal.gdb"+ "\\" # not working!!!
#loop for multiply by 100 and divide by LPAWC to get percent nFK
for LPAWC_ras, LPAWFC_ras in zip(rasters_LPAWC, rasters_LPAWFC):
r1 = Raster(LPAWC_ras)
r2 = Raster(LPAWFC_ras)
output_raster2 = 100*r1/r2
out_raster2 = folder2 + arcpy.Describe(r1).baseName + "_prznFK" #'{}{}'.format(r1,"_prznFK")
output_raster2.save(out_raster2)
print("{} Processed Successfully!".format(out_raster2))
Cheers for any help!
Ingo