ENVITaskEngine Examples
The following examples show some common scenarios of running ENVI analytics at the command line.
Query the ENVITask Catalog
Use ENVIQueryTaskCatalogTask to get a list of available ENVITasks. The following steps show how to use this task with the envitaskengine executable:
- Start a terminal window.
- Create a scratch directory with write permissions, where any temporary output can be written. Change to that directory:
mkdir sandbox
cd sandbox
- Run the QueryTaskCatalog task from envitaskengine on a single line:
Bash shell:
echo '{"taskName":"QueryTaskCatalog"}' | /usr/local/harris/envi/bin/envitaskengine
Windows terminal:
echo {"taskName":"QueryTaskCatalog"} | "C:\Program Files\Harris\envixx\idlxx\bin\bin.x86_64\envitaskengine"
Query a Task for its Parameters
Once you have selected a specific task of interest, use ENVIQueryTaskTask to get information about its input and output parameters. The following steps show how to use ENVIQueryTaskTask with the envitaskengine executable:
- Start a terminal window.
- Create a scratch directory with write permissions, where any temporary output can be written. Change to that directory:
mkdir sandbox
cd sandbox
- Run the QueryTask task from envitaskengine on a single line:
Bash shell:
echo '{"taskName":"QueryTask","inputParameters":{"Task_Name":"SpectralIndex"}}' | /usr/local/harris/envi/bin/envitaskengine
Windows terminal:
echo {"taskName":"QueryTask","inputParameters":{"Task_Name":"SpectralIndex"}} | "C:\Program Files\Harris\envixx\idlxx\bin\bin.x86_64\envitaskengine"
- To view an error generated during task execution, run the above command with a fake task name:
Bash shell:
echo '{"taskName":"QueryTask","inputParameters":{"Task_Name":"DoesNotExist"}}' | /usr/local/harris/envi/bin/envitaskengine
Windows terminal:
echo {"taskName":"QueryTask","inputParameters":{"Task_Name":"DoesNotExist"}} | "C:\Program Files\Harris\envixx\idlxx\bin\bin.x86_64\envitaskengine"
Run the Spectral Index Task
ENVI provides many tasks that you can run with your data. See Data Processing Routines for a list of available ENVITasks. The following example shows how to run ENVISpectralIndexTask with a QuickBird image located in the ENVI installation path.
Note: You would normally run ENVIQuerySpectralIndicesTask first to see what indices you can compute on an image before running ENVISpectralIndexTask. This example does not use ENVIQuerySpectralIndicesTask.
- Start a terminal window.
- Create a scratch directory with write permissions, where the output will be written. Change to that directory:
mkdir sandbox
cd sandbox
- Create a spectralIndex.json file in the scratch directory with the following JSON code.
Tip: On Windows systems, update the URL key to "C:\\Program Files\\Harris\\envixx\\data\\qb_boulder_msi".
{
"taskName": "SpectralIndex",
"inputParameters": {
"Input_Raster": {
"Factory": "URLRaster",
"URL": "/usr/local/harris/envi/data/qb_boulder_msi"
},
"Index": "Normalized Difference Vegetation Index"
}
}
- Run the SpectralIndex task from the envitaskengine executable using the newly created file:
Bash shell:
/usr/local/harris/envi/bin/envitaskengine < spectralIndex.json
Windows terminal:
"C:\Program Files\Harris\envixx\idlxx\bin\bin.x86_64\envitaskengine" < spectralIndex.json
- Notice that the output is written to the scratch directory. If you want the output in a different location, set the Output_Raster_URI parameter of the SpectralIndex task.
- To process a spatial subset of the image, update the spectralIndex.json file as follows.
Tip: On Windows systems, update the URL key to "C:\\Program Files\\Harris\\envixx\\data\\qb_boulder_msi". Also see Supported Data Types for details on specifying ENVI and IDL data types for the envitaskengine executable.
{
"taskName": "SpectralIndex",
"inputParameters": {
"Input_Raster": {
"Factory": "SubsetRaster",
"Sub_Rect": [600,200,799,399],
"Input_Raster": {
"factory": "URLRaster",
"URL": "/usr/local/harris/envi/data/qb_boulder_msi"
}
},
"Index": "Normalized Difference Vegetation Index"
}
}
- Run the updated Spectral Index task from the envitaskengine executable using the newly created file. Notice that the generated file is smaller since it is a spatial subset of the original image.
Bash shell:
/usr/local/harris/envi/bin/envitaskengine < spectralIndex.json
Windows terminal:
"C:\Program Files\Harris\envixx\idlxx\bin\bin.x86_64\envitaskengine" < spectralIndex.json