ENVITaskEngine Examples
The following examples show some common scenarios of running ENVI analytics at the command line.
Query the ENVITask Catalog
Use the QueryTaskCatalog task 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:
- Run the QueryTaskCatalog task from envitaskengine on a single line:
mkdir sandbox
cd sandbox
Bash shell:
echo '{"taskName":"QueryTaskCatalog"}' | /usr/local/INSTALL_DIR/envi/bin/envitaskengine
Windows terminal:
echo {"taskName":"QueryTaskCatalog"} | "C:\\Program Files\\INSTALL_DIR\ENVIxx\IDLxx\bin\bin.x86_64\envitaskengine"
Query a Task for its Parameters
Once you have selected a specific task of interest, use the QueryTask task 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:
- Run the QueryTask task from envitaskengine on a single line:
- To view an error generated during task execution, run the above command with a fake task name:
mkdir sandbox
cd sandbox
Bash shell:
echo '{"taskName":"QueryTask","inputParameters":{"Task_Name":"SpectralIndex"}}' | /usr/local/INSTALL_DIR/envi/bin/envitaskengine
Windows terminal:
echo {"taskName":"QueryTask","inputParameters":{"Task_Name":"SpectralIndex"}} | "INSTALL_DIR\envixx\idlxx\bin\bin.x86_64\envitaskengine"
Bash shell:
echo '{"taskName":"QueryTask","inputParameters":{"Task_Name":"DoesNotExist"}}' | /usr/local/INSTALL_DIR/envi/bin/envitaskengine
Windows terminal:
echo {"taskName":"QueryTask","inputParameters":{"Task_Name":"DoesNotExist"}} | "INSTALL_DIR\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 the SpectralIndex task with a QuickBird image located in the ENVI installation path.
Note: You would normally run the QuerySpectralIndices task first to see what indices you can compute on an image before running the SpectralIndex task. This example does not use the QuerySpectralIndices task.
- Start a terminal window.
- Create a scratch directory with write permissions, where the output will be written. Change to that directory:
- Create a
spectralIndex.json
file in the scratch directory with the following JSON code. - Run the SpectralIndex task from the envitaskengine executable using the newly created file:
- 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. - 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.
mkdir sandbox
cd sandbox
Tip: On Windows systems, update the URL key to "C:\\Program Files\\INSTALL_DIR\\envixx\\data\\qb_boulder_msi"
.
{
"taskName": "SpectralIndex",
"inputParameters": {
"Input_Raster": {
"Factory": "URLRaster",
"URL": "/usr/local/INSTALL_DIR/envi/data/qb_boulder_msi"
},
"Index": "Normalized Difference Vegetation Index"
}
}
Bash shell:
/usr/local/INSTALL_DIR/envi/bin/envitaskengine < spectralIndex.json
Windows terminal:
"INSTALL_DIR\envixx\idlxx\bin\bin.x86_64\envitaskengine" < spectralIndex.json
Tip: On Windows systems, update the URL key to "C:\\Program Files\\INSTALL_DIR\\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/INSTALL_DIR/envi/data/qb_boulder_msi"
}
},
"Index": "Normalized Difference Vegetation Index"
}
}
Bash shell:
/usr/local/INSTALL_DIR/envi/bin/envitaskengine < spectralIndex.json
Windows terminal:
"INSTALL_DIR\envixx\idlxx\bin\bin.x86_64\envitaskengine" < spectralIndex.json