0

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 *  

workspace1 = glob.glob(r"D:\MODIS-NDVI-2012\MASKED-NDVI-2012A") 
workspace2 = glob.glob(r"D:\MODIS-NDVI-2012\MASKED")
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)

1 Answer 1

1

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.

6
  • the error massage is Parsing error SyntaxError: invalid syntax (line 14) Commented Aug 17, 2016 at 15:07
  • You need to add ":" after the for statement in line 14 and indent the following block of code to the right Commented Aug 17, 2016 at 15:15
  • Would you please copy and paste the corrected line . Commented Aug 17, 2016 at 15:17
  • I will add it in a separate answer Commented Aug 17, 2016 at 15:19
  • @MohannadAdham please don't add as a separate answer - you can edit this one and add to it.
    – Midavalo
    Commented Aug 17, 2016 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.