# Calculate list of raster from two different folder using ArcPy?

I have two different folder (workspace1 and workspace2) with Rasters data with the two different parameters. Whatever raster in workspace1 (input raster name e.g 001_mean, 002_mean, 003_mean, 004_mean ….012_mean ), I would like to execute below equation

``````((Raster – Min Rater value) * (0.95 – 0.01)) / (Max raster value – Min Raster Value )
``````

and save it into outputfolder 1 name of output (e.g. 001_FPAR, 002_FPAR, 003_FPAR, 004_FPAR ….012_FPAR)

After calculating workspace1, I want to take different raster file from workspace 2 (raster name , 001_SR, 002_SR, 003_SR, 004_SR……012_SR) and multiply it with each raster file with calculated raster from workspace 1 and save it into outputfolder 2 as name of 001_APAR, 002_APAR, 003_APAR, 004_APAR ……012_APAR.

I have written the code below but its giving error.

``````import arcpy
arcpy.CheckOutExtension("Spatial")
from arcpy.sa import *

outFolder1 =  r"D:\MODIS-NDVI-2012\FPAR"
outFolder2 =  r"D:\MODIS-NDVI-2012\APAR"

list = arcpy.ListRasters()

for inRaster in list:
localRaster = Raster(inRaster)
for r in workspace1
NDVIMINResult = arcpy.GetRasterProperties_management(inRaster1, "MINIMUM")
NDVIMAXResult = arcpy.GetRasterProperties_management(inRaster1, "MAXIMUM")

NDVIMin = float(NDVIMINResult.getOutput(0))
NDVIMax = float(NDVIMAXResult.getOutput(0))
outminus = Minus(inRaster1, NDVIMin)
outminus1 = Minus(0.95-0.01)
outmultiply = Multiply(outminus,outminus1)
outminus2 = Minus(NDVIMax, NDVIMin)
outdevide = Devide(outmultiply,outminus2)
outdevide.save = (outdevide)
for r in workspace2
outmultiply1 = Multiply (outdevide,Raster)
outmultiply1.save (outmultiply1)
``````

Could you please copy the error message you received and paste it here? I cant be sure without seeing the error message but I think that you have a problem with the following line

``````outminus1 = Minus(0.95-0.01)
``````

Here you used one parameter with the function "Minus" instead of two.

Update:

Here are the corrected lines:

``````for r in workspace1:
NDVIMINResult = arcpy.GetRasterProperties_management(inRaster1, "MINIMUM")
NDVIMAXResult = arcpy.GetRasterProperties_management(inRaster1, "MAXIMUM")
``````

You should pay attention to the indentation of the block of code that follows the for statement.

• the error massage is `Parsing error SyntaxError: invalid syntax (line 14)` – Shouvik Jha Aug 17 '16 at 15:07
• You need to add ":" after the for statement in line 14 and indent the following block of code to the right – Mohannad Adham Aug 17 '16 at 15:15
• Would you please copy and paste the corrected line . – Shouvik Jha Aug 17 '16 at 15:17