X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 09 Oct 2014 03:54 AM by  anon
ndvi_batch
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
09 Oct 2014 03:54 AM
    Hi, I'm very new in IDL. I want to calculate NDVI indice for a lot of images with got from private company. I found in this forum a pro code and i tryed to adapt it but it not working. Please check and tell me what is wrong. pro ndvi_batch compile_opt idl2 ;set up path to input and output files ;input_path = 'X:\JEdi_D2\GrassService\Siguldas_nov\Process\140708\112717_2' ;change to output directory where I want the processed files to be placed cd, 'X:\JEdi_D2\GrassService\Siguldas_nov\Process\140708\112717' ; search for data files in the specified directory files = FILE_SEARCH('X:\JEdi_D2\GrassService\Siguldas_nov\Process\140708\112717\CASI_2014_07_08_112717_g.pix', 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 ;set pos array for calculating NDVI pos = [21,10] - 1 ;set the output file names by stripping out the base name and appending 'ndvi.img' out_name = file_basename(filename,'.dat')+'_NDVI.dat' ;call the doit envi_doit, 'ndvi_doit', $ fid=fid, pos=pos, dims=dims, $ /check, o_min=0, o_max=255, $ out_name=out_name, r_fid=r_fid endfor end IDL> ndvi_batch % Compiled module: NDVI_BATCH. % Expression must be a scalar or 1 element array in this context: . % Execution halted at: NDVI_BATCH 18 X:\JEdi_D2\!IDL_darbs\ndvi_batch.pro % $MAIN$

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    21 Oct 2014 07:44 AM
    If your FID returns -1, ENVI was unable to find any valid files. Did your 'COUNT' return anything? You might try ENVI_OPEN_DATA_FILE with the /pci keyword or the OpenRaster method using the PCI type in the ENVI 5.x API.

    Deleted User



    New Member


    Posts:7
    New Member


    --
    11 Nov 2014 05:39 AM
    Hi Helujanus, I suspect that ENVI is returning multiple FIDs when you open your images. What kind of images are you working with? Which format? In some cases, mainly due to the presence of bands with different resolutions, ENVI opens one single file as multiple images and the result of the FID parameter is a vector. It is very simple to check. When you open one of your images from ENVI menu, how many images or datasets do you see in the Data Manager or the Available Bands List? Your error message makes me think that one of your files will contain 10 datasets. Imanol
    You are not authorized to post a reply.