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:

  1. Start a terminal window.
  2. Create a scratch directory with write permissions, where any temporary output can be written. Change to that directory:
  3. mkdir sandbox
    cd sandbox
  4. Run the QueryTaskCatalog task from envitaskengine on a single line:
  5. 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:

  1. Start a terminal window.
  2. Create a scratch directory with write permissions, where any temporary output can be written. Change to that directory:
  3. mkdir sandbox
    cd sandbox
  4. Run the QueryTask task from envitaskengine on a single line:
  5. 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"
  6. To view an error generated during task execution, run the above command with a fake task name:
  7. 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.

  1. Start a terminal window.
  2. Create a scratch directory with write permissions, where the output will be written. Change to that directory:
  3. mkdir sandbox
    cd sandbox
  4. Create a spectralIndex.json file in the scratch directory with the following JSON code.
  5. 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"
          }
    }
  6. Run the SpectralIndex task from the envitaskengine executable using the newly created file:
  7. Bash shell:

    /usr/local/INSTALL_DIR/envi/bin/envitaskengine < spectralIndex.json

    Windows terminal:

    "INSTALL_DIR\envixx\idlxx\bin\bin.x86_64\envitaskengine" < spectralIndex.json
  8. 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.
  9. To process a spatial subset of the image, update the spectralIndex.json file as follows.
  10. 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"
          }
    }
  11. 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.
  12. Bash shell:

    /usr/local/INSTALL_DIR/envi/bin/envitaskengine < spectralIndex.json

    Windows terminal:

    "INSTALL_DIR\envixx\idlxx\bin\bin.x86_64\envitaskengine" < spectralIndex.json