Hi,
How can i make a division of more than two raster with arcpy?
Do you mean how to do something like (raster1/raster2)/raster3? See help here. You just turn them into raster objects and divide:
outRaster = (Raster(raster1)/Raster(raster2))/Raster(raster3)
I have two sets of rasters (r_rain_m1 * up to m10 and r_weight_m1 * up to10) in two folders (folder_rain and folder_weight), and I want to split r_rain rasters between r_weight.
For example, r_rain_m1 / r_weight_m1, r_rain_m2 / r_wieght_m2, ...
Thanks for the help!
I'd create a separate list of raster for each folder using the List Rasters function. http://pro.arcgis.com/en/pro-app/arcpy/functions/listrasters.htm
I'd iterate through one list to use as the first input for the Divide function and use an index to pull the appropriate raster from the second list of rasters.
import arcpy
import os
arcpy.CheckOutExtension("Spatial")
output_path = r"pathtooutputfolder"
rain_folder = r"pathtorainfolder"
weight_folder = r"pathtoweightfolder"
rain_list = arcpy.ListRasters(rainfolder)
weight_folder = arcpy.ListRasters(weight_folder)
count = 0
for ras in rainlist:
outDivide = arcpy.sa.Divide(ras, weight_list[count])
outDivide.save(os.path.join(output_path, " r_divide_m" + str(count + 1) + ".tif")
count += 1
del outDivide