1

I am trying to calculate EVI from MODIS data in Arc. I know how to run one raster group of 3 bands but don't know how to tell it to move on to the next group of 3 bands in that directory. Here is the formula EVI = 2.5 * (NIR-Red)/(NIR+6*Red-7.5*Blue+1). So ideally I would like it to run a directory of many tiles with their bands in order from 1-3.

2 Answers 2

3

The following assumes you have ArcGIS 10.2 and the Spatial Analyst extension. If you have the Spatial Analyst extension available to you, I'm pretty sure the ArcPy.sa Raster Object can be used to apply the *EVI = 2.5 * (NIR-Red)/(NIR+6*Red-7.5*Blue+1)* formula across all MODIS rasters in your directory. I'm thinking we need these steps:

  • Get a list of all of the MODIS raster datasets in the directory (the trickery shown below with the paths here is a poor hack, there is probably a better way)
  • For each MODIS raster identify NIR, BLUE, and RED bands. Create a Raster Object for each.
  • Use math expressions on the Raster Objects to get the EVI output raster

The code may look something like:

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

env.workspace = "The\\Modis\\Rasters\\Directory"

RasterList = arcpy.ListRasters()

counter = 1
for Rasteroo in RasterList:
    RedBand = arcpy.Raster(env.workspace + "\\" + Rasteroo + "\\" + "Band_1") # here,    we can create raster objects from single bands in a raster dataset
    BlueBand = arcpy.Raster(env.workspace + "\\" + Rasteroo + "\\" + "Band_2")
    NIRBand = arcpy.Raster(env.workspace + "\\" + Rasteroo + "\\" + "Band_3")

    EVI_Raster = 2.5 * (NIRBand - RedBand)/(NIRBand + (6 * RedBand) - (7.5 * BlueBand) + 1) # Is this math correct to your EVI formula?

    EVI_Raster.save(env.workspace + "\\" +  "EVI_Raster_" + str(counter))

    counter +=1

Best Luck with this.

1
  • After I enter:RedBand = arcpy.Raster(env.workspace + "\\" + Rasteroo + "\\" + "Band1") BlueBand = arcpy.Raster(env.workspace + "\\" + Rasteroo + "\\" + "Band2") I get the following error: RuntimeError: ERROR 000732: Input Raster: Dataset Z:\E\MRT\MRT_download_Win\Out_2\float\mcd43b4.a2011353.h08v04.005.2012007011256.nadir_reflectance_band1.tif.flt\band1 does not exist or is not supported In the error I can see it finds the raster but then tries to add a folder extension from the raster name as band1. Instead I want it to pick the raster with the extension of band1.
    – Maggi
    Oct 15, 2014 at 21:59
0

Just use model builder.

Step 1 iterate your rasters.

enter image description here

Select the folder or Geodatabase of all your rasters on the left.

Step 2. would be (many options here but I would use map algebra) put your math into the Single Map Algebra Function. Remember to specify the bands.

Then use this for the output name EVI%Name%

This will result in one output file in your output geodatabase or folder named EVIinputname with the EVI result. You can do hundreds overnight.

HINT -- if your inputs are Integer and you want decimals in the output (I think this will be the case, it almost always is) they just add a FLOAT command between the Iterator and the Raster Calculator (I process EVI often...). Otherwise you get zero for everyone.

1
  • What I don't understand with the model builder method is how I distinguish the bands in the raster calculator. When you link the arrow from the raster (or converted float) it only gives you one choice of raster but the EVI equation has all three bands. In the directory all the tiles are labeled with their tile and band number.
    – Maggi
    Oct 13, 2014 at 15:56

Your Answer

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

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