X

NV5 Geospatial Blog

Each month, NV5 Geospatial posts new blog content across a variety of categories. Browse our latest posts below to learn about important geospatial information or use the search bar to find a specific topic or author. Stay informed of the latest blog posts, events, and technologies by joining our email list!



New ENVI Agent, IDL Agent, and GeoAgent Quick Guides

New ENVI Agent, IDL Agent, and GeoAgent Quick Guides

6/9/2026

The recent release of ENVI® Agent, IDL® Agent, and GeoAgent™ revolutionize how users interact with geospatial software. These agentic AI applications act as partners to plan, simplify, and execute complex workflows. Knowing where to start can be challenging for new users. To this end, we developed three new quick guides to... Read More >

Introducing NISAR Data Support

Introducing NISAR Data Support

6/5/2026

The release of ENVI® SARscape 6.3 in April 2026 includes preliminary support for NASA-ISRO SAR (NISAR) data. The NISAR mission is a joint Earth-observing satellite project between NASA and the Indian Space Research Organization designed to monitor changes in the planet’s land and ice surfaces using advanced radar imaging. It... Read More >

Monitoring Illegal Mining in the Amazon: Turning Persistent Data Into Actionable Insight

Monitoring Illegal Mining in the Amazon: Turning Persistent Data Into Actionable Insight

5/28/2026

Illegal mining over decades has constituted one of the most persistent and complex socio-environmental problems in the Brazilian Amazon. In recent years, with the increasingly intensive use of mechanized extraction, the associated environmental impacts—such as deforestation, intense soil disturbance, river siltation, and mercury... Read More >

From Answers to Action: Why ENVI and IDL Agents Go Beyond General AI

From Answers to Action: Why ENVI and IDL Agents Go Beyond General AI

4/20/2026

As generative AI tools like Claude and Gemini continue to gain traction, many organizations are asking the same question: Can general purpose AI actually support real geospatial workflows, or does it stop at surface-level answers? That question was front and center in our recent webinar, Meet Your New Partners in Science: ENVI... Read More >

Mapping Earthquake Deformation in Taiwan With ENVI

Mapping Earthquake Deformation in Taiwan With ENVI

12/15/2025

Unlocking Critical Insights With ENVI® Tools Taiwan sits at the junction of major tectonic plates and regularly experiences powerful earthquakes. Understanding how the ground moves during these events is essential for disaster preparedness, public safety, and building community resilience. But traditional approaches like field... Read More >

1345678910Last
«June 2026»
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
23107 Rate this article:
2.8

Batch Processing using an ENVITask

Anonym

Last week, Brian Griglak outlined how to subset an ENVIRaster for use with an ENVITask on IDL Data Point. This functionality is used frequently, but what if you need to go the other direction? What if you need to process multiple files in a single script?

By running a batch process in the ENVI API, you can run a single process (or a chain of processes for that matter) on a list of files, and output the results to a location of your choosing.

An ENVI batch script using ENVITasks must contain 5 elements to run properly:

  • Start the ENVI application, preferably in HEADLESS mode since the UI is not needed.
  • Initialize the ENVITask and set constant parameters.
  • Generate a list of input files to do processing on.
  • Create an output filename - one for each input file.
  • Run the processing over each file in a loop with the parameters of your choice.

 

A lot of the work in creating a batch script does not stem from doing processing, but rather from managing input and output files. The code below outlines how this minimum framework can be setup using the RadiometricCalibration task.

 

pro batch_radiometric_calib

 compile_opt idl2

 

 ;Start ENVI in headless mode

 e = envi(/headless)

 

 ;Instantiate the ENVITask, set constant parameters.

 task = ENVITask('Radiometric')

 task.CALIBRATION_TYPE = 1

 

 ;Find all the files with .dat extensions in a directory.

 search_dir = 'Directory of files to calibrate'

 filelist = file_search(search_dir + '*.dat')

 ;Set a base for your output files that will be appended to.

 outbase = 'C:\Scratch\Reflectance_Cal_'

 

 ;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

 

One cool thing about using an ENVITask for batch processing is that each time through the loop, you only have to change the parameters that... well.. change!

 

In the example above, the CALIBRATION_TYPE is set to 1 (to calibrate to top of atmosphere reflectance) outside the loop so it is only set one time. The input_raster and output_raster are set inside the loop - they will change for each file.

At the end of the loop, with the new parameters in place, task.Execute is called. This kicks off processing of the ENVITask with the current parameters, but leaves the task unchanged for subsequent use.

 

To access the current list of ENVITasks:

IDL> e=envi()

ENVI> e.TASK_NAMES

 

For help on functions used in the example:

STRTRIM, FILE_SEARCH, OPENRASTER, COMPILE_OPT
 

 

Happy batching!

1 comments on article "Batch Processing using an ENVITask"

Avatar image

Ivan Alvarez

I have this problem when I try to make a batch proccess

ERROR: Insufficient keyword directives

My code is this

; Add the extension to the toolbox. Called automatically on ENVI startup.

pro test2_extensions_init

; Set compile options

compile_opt IDL2

; Get ENVI session

e = ENVI(/CURRENT)

; Add the extension to a subfolder

e.AddExtension, 'test2', 'test2', PATH=''

end

; ENVI Extension code. Called when the toolbox item is chosen.

pro test2

; Set compile options

compile_opt IDL2

; General error handler

CATCH, err

if (err ne 0) then begin

CATCH, /CANCEL

if OBJ_VALID(e) then $

e.ReportError, 'ERROR: ' + !error_state.msg

MESSAGE, /RESET

return

endif

;Get ENVI session

e = ENVI(/CURRENT)

;******************************************

; Insert your ENVI Extension code here...

;******************************************

;Start ENVI in headless mode

e = envi(/headless)

;Instantiate the ENVITask, set constant parameters.

task = ENVITask('RadiometricCalibration')

task.CALIBRATION_TYPE = 'Radiance'

;Find all the files with .dat extensions in a directory.

CD = 'C:'

search_dir = '../test'

filelist = file_search(search_dir + '*.txt')

;Set a base for your output files that will be appended to.

outbase = 'C:\Scratch\Reflectance_Cal_'

;Loop over every file.

;Open the raster, set parameters, and execute the task.

foreach file, filelist, index do begin

raster = e.OpenRaster(file)

OLIBands = raster[0]

task.input_raster = OLIBands

task.output_raster_uri = outbase + strtrim(index, 2)

task.Execute

endforeach

end

Please login or register to post comments.