X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 20 Jun 2016 06:48 AM by  anon
Landsat 8 Radiometric Calibration
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
20 Jun 2016 06:48 AM
    Dear All Out of https://www.harrisgeospatial.com/docs/enviradiometriccalibrationtask.html, I took the L8Calibrate.pro example, did the modification that is suitable to my needs. Although when running it this message is appearing: % Expression must be a scalar or 1 element array in this context: . % Execution halted at: $MAIN$ Here is the modified script: PRO L8CALIBRATE COMPILE_OPT IDL2 ; Start the application e = ENVI(/HEADLESS) ; A Landsat 8 OLI dataset consists of one TIFF file per band, ; with an associated metadata file (*_MTL.txt). Open the ; metadata file to automatically read the gains and offsets. File = File_Search('C:\Users\cesar.guerreiro\Desktop\PROP_PPGG\Trial1\LC8', '*_MTL.txt') Raster = e.OpenRaster(File) ; Get the radiometric calibration task from the catalog of ENVI tasks. Task = ENVITask('RadiometricCalibration') ; Define inputs. Since radiance is the default calibration method ; you do not need to specify it here. Task.Calibration_Type = 'Top-of-Atmosphere Reflectance' Task.Input_Raster = Raster[0] ; Bands 1-7 Task.Output_Data_Type = 'Float' ; Define output raster URI Task.Output_Raster_URI = e.GetTemporaryFilename() ; Run the task Task.Execute ; Get the data collection DataColl = e.Data ; Add the output to the data collection DataColl.Add, Task.Output_Raster ; Close the ENVI session e.Close END -------- printing File, as print, File, my list is there: C:\Users\cesar.guerreiro\Desktop\PROP_PPGG\Trial1\LC8\LC82170762016111LGN00_MTL.txt C:\Users\cesar.guerreiro\Desktop\PROP_PPGG\Trial1\LC8\LC82200782016164LGN00_MTL.txt C:\Users\cesar.guerreiro\Desktop\PROP_PPGG\Trial1\LC8\LC82200792016164LGN00_MTL.txt C:\Users\cesar.guerreiro\Desktop\PROP_PPGG\Trial1\LC8\LO82220612013153LGN00_MTL.txt What I am letting pass by? Thanks in advance Diniz

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    20 Jun 2016 08:50 AM
    In the example code, they are passing a single file but in your case, you are passing an array of files. To process a batch of files, you will need to use an iterator such as a FOR or a FOREACH loop: Here is an example: http://www.harrisgeospati...ing-an-ENVITask.aspx

    Deleted User



    New Member


    Posts:
    New Member


    --
    20 Jun 2016 09:34 AM
    Thanks...working fine now.

    Deleted User



    New Member


    Posts:
    New Member


    --
    20 Jun 2016 12:59 PM
    Not that fine...there is a problem within the 'task.input_raster = raster' now. The following error message is appearing: Problem: An error was encoutered opening this file. Error: Attempt to subscript with POS is out of range. Here is the modified Script.. --- pro batch_radiometric_calib compile_opt idl2 ;Start ENVI in headless mode e = envi(/headless) ;Instantiate the ENVITask, set constant parameters. task = ENVITask('RadiometricCalibration') task.CALIBRATION_TYPE = 'Top-of-Atmosphere Reflectance' ;Find all the files with .dat extensions in a directory. search_dir = '/Users/cesar.guerreiro/Desktop/PROP_PPGG/Trial1/LC8/' filelist = file_search(search_dir + '*_MTL.txt') ;Set a base for your output files that will be appended to. outbase = '/Users/cesar.guerreiro/Desktop/PROP_PPGG/Trial1/LC8/CalTOA/' ;Loop over every file. ;Open the raster, set parameters, and execute the task. foreach file, filelist, index do begin raster = e.OpenRaster(file) task.input_raster = raster task.output_raster_uri = outbase + strtrim(index, 2) task.Execute endforeach end --- The filelist is printing normaly, C:\Users\cesar.guerreiro\Desktop\PROP_PPGG\Trial1\LC8\LC82170762016111LGN00_MTL.txt C:\Users\cesar.guerreiro\Desktop\PROP_PPGG\Trial1\LC8\LC82200782016164LGN00_MTL.txt C:\Users\cesar.guerreiro\Desktop\PROP_PPGG\Trial1\LC8\LC82200792016164LGN00_MTL.txt C:\Users\cesar.guerreiro\Desktop\PROP_PPGG\Trial1\LC8\LO82220612013153LGN00_MTL.txt 4 MTL files Thanks in advance
    You are not authorized to post a reply.