X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 09 Jan 2009 04:00 AM by  anon
MATH DO IT using 3 bands for EVI calculation
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
09 Jan 2009 04:00 AM
    Hi guys, Im just new in using IDL. Last time I posted here, I got help from this forum on how to use MATH DO IT for vegetation indices calculation, i.e. NDVI and LSWI which uses 2 bands for calculation (red and NIR). It worked! Thank you. I tried using the same script for "EVI" and just changed the equation and bands since it uses 3 bands for calculation (RED,NIR,BLUE bands). QUESTION about MATH DO IT:  Does it work for 3 input bands? Or its just limited to 2 input bands? If any of you have time, can you help me please to figure out whats wrong with the script? Or if you have any sugestion on what I can use for EVI calculation.  Im processing tons of images, and doing it one by one in ENVI Band math would consume lots of time. Thank you very much in advance. Here's the script I used and the error: pro evi_math_doit compile_opt idl2 input_path = 'E:\aRiceMapping\xENVI_test\Sinu\2007\' cd, 'E:\aRiceMapping\xENVI_test\Sinu\EVI\' files=FILE_SEARCH(input_path+'*.tif', count=count) IF(count EQ 0)THEN BEGIN PrintF, 'No files were found to process' ENDIF for i=0, count-1 do begin     envi_open_file, files[i], r_fid=fid     if(fid eq -1) then begin         envi_batch_exit         return     endif envi_file_query, fid, dims=dims, ns=ns, nl=nl, fname=filename t_fid=[fid,fid] ;set pos array for calculation EVI pos = [2,3,0] exp = '2.5*(b1-b2)/(b1+(6*b2)-(7.5*b3)+1)' ;set the oputput filenames by stripping out the base name and appending 'ndvi.img' out_name = file_basename(filename,'.tif')+'_lswi.tif' ;call the doit envi_doit,'math_doit',$     fid=t_fid, pos=pos, dims=dims,$     exp=exp, out_name=out_name, $     r_fid=r_fid  endfor end ERROR: math_doit: An error has occured during processing Error: "Attempt to subscript FID with I is out of range." The result may be invalid     Sincerely, ONYANG

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    15 Jan 2009 10:03 AM
    Yes, MATH_DOIT can work with any number of bands but you have to be sure to address all those bands when using the FID and POS arrays.  For example, you only have a 2 band FID array as it is now.  You need to have a FID for every input band.  Try adding another FID in the array.  It looks like you have already included the 3 bands in the POS array.
    You are not authorized to post a reply.