12 Feb 2015 06:50 AM |
|
Hi,
I try to calibrate a number of landsat 7 images in batch mode and I want to use '' ENVIRadiometricCalibrationTask'' command, but I received this error '' Attempt to call undefined procedure/function: 'ENVITASK' ''
First I thought that the problem is in ''COMPILE_OPT IDL'' and I changed in into the other suggestion but still I faced this error.Should I have additional licence to use ''ENVITask'' ??Is there any solution for my problem?
Regards,
|
|
|
|
MariM Veteran Member
Posts:2396  
12 Feb 2015 09:46 AM |
|
You must initiate ENVI batch in order for IDL to recognize ENVI routines such as the radiometric calibration task.
e = ENVI(/HEADLESS)
and
e.Close
|
|
|
|
Deleted User New Member
Posts:  
12 Feb 2015 03:25 PM |
|
Another question to consider would be which version of ENVI you are working with. The majority of ENVITasks made their way into ENVI at version 5.2, so if you have a previous version of ENVI, I would expect an error like that since ENVI would not know what to do with it.
For reference, here is my code for radiometrically calibrating Landsat data using ENVIRadiometricCalibrationTask in ENVI 5.2 in headless mode (just make sure to edit my file paths):
PRO Landsat_RadCal_Batch
compile_opt idl2
; Start the application
e = ENVI(/HEADLESS)
; A Landsat dataset consists of one or more TIFF files,
; with an associated metadata file (*MTL.txt). Open the
; metadata file to automatically read the gains and offsets
; necessary to perform radiometric calibration.
; Create a list of input files to perform radiometric calibration
filelist = File_Search('C:\Data\Landsat\SierraReservoirs', '*MTL.txt')
; Get the radiometric calibration task from the catalog of ENVI tasks.
Task = ENVITask('RadiometricCalibration')
; Define the output data type and calibration type
Task.Output_Data_Type = 'Float'
Task.Calibration_Type = 'Top-of-Atmosphere Reflectance'
; Define output location
out_dir = 'C:\Data\Landsat\SierraReservoirs\RadCal'
; Loop over every file.
; Open the raster, set parameters, and execute the task.
foreach file, filelist do begin
output_file = out_dir + path_sep() + 'radio_' + file_basename(file)
raster = e.OpenRaster(file)
task.input_raster = raster[0]
task.output_raster_uri = output_file
task.Execute
endforeach
; 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
|
|
|
|
Deleted User New Member
Posts:  
13 Feb 2015 02:25 AM |
|
Thanks for your answers
I think I find the problem. I have ENVI 5.0.2 and I think this version does not support ''Radiometric Calibration'' as a task. So I must generate my own function based on 'TMCAL_DOIT' routine. Unfortunately I find that this routine just works with old-style metadata file of LandSat. Is there any suggestion for my problem?
Best Regards,
|
|
|
|
Deleted User New Member
Posts:59  
13 Feb 2015 09:26 AM |
|
Hello,
The TMCAL_DOIT routine was updated to work with the new Landsat metadata files. In your code, open the associated metadata file (_MTL.txt), then set the /USE_METADATA keyword. Please see http://www.exelisvis.com/docs/TMCAL_DOIT.html for details. the TMCAL_DOIT help topic in the ENVI Classic help may also have a code example.
|
|
|
|
Deleted User New Member
Posts:  
|
Deleted User New Member
Posts:  
31 Mar 2015 08:27 PM |
|
To>> joe peters
Hi, I also have problem with doing landsat8 calibration, and I am newbie using envi/idl :D
I am using Envi 5.1 and IDL 8.3
I have tried code, called ENVIRadiometricCalibrationTask provided by Exelis VIS >
and I also have tried your posting code. After compiled and run the program, the execution halted with this error message
"Input value is of type STRING, which cannot be reliably cast to numeric type INT"
the error message refer to below line
; Define the output data type and calibration type
Task.Output_Data_Type = 'String'
Task.Calibration_Type = 'Top-of-Atmosphere Reflectance'
I could not find how to convert string to integer type, could you please help me?
By the way, does your posted program run well in your IDL?
thanks ^_^
|
|
|
|
MariM Veteran Member
Posts:2396  
01 Apr 2015 08:00 AM |
|
Why are you setting the output data type of your raster to a string?
Task.Output_Data_Type = 'String'
It is a raster, so you will want the pixels to be represented by integers, floats, etc. The data type options are:
OUTPUT_DATA_TYPE (optional)
Specify a string indicating the output data type:
Int: 16-bit integer
Float: Floating-point (default)
Double: Double-precision floating point
UInt: 16-bit unsigned integer
In the example code they use a string to specify the data type:
Task.Output_Data_Type = 'Double'
|
|
|
|
Deleted User New Member
Posts:  
02 Apr 2015 05:29 AM |
|
Task.Output_Data_Type = 'String'
Sorry, I have mistyped above line
but actually I have tried the code with output data type set as float
Task.Output_Data_Type = 'Float'
and the error message: " Input value is of type STRING, which cannot be reliably cast to numeric type INT"
|
|
|
|
MariM Veteran Member
Posts:2396  
02 Apr 2015 07:41 AM |
|
This appears to work correctly in ENVI 5.2 so it may have been a bug in 5.1. Can you upgrade to 5.2?
|
|
|
|