Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


Harris Geospatial / Docs Center / ENVI API / Crop Science / ENVIAgCalculateAndRasterizeCropMetricsWithSpectralIndexTask

ENVIAgCalculateAndRasterizeCropMetricsWithSpectralIndexTask

ENVIAgCalculateAndRasterizeCropMetricsWithSpectralIndexTask

This task creates a spectral index image and calculates statistics from it and from an associated ENVIAgCrops object. It creates a classification raster showing the relative means of crops or a grayscale raster showing actual mean values of crops. For example, if the input raster is a vegetation index such as NDVI, the crop means describe the health of the crops.

ENVIAgCalculateAndRasterizeCropMetrics is a metatask that runs the following tasks:

  • ENVISpectralIndexRasterTask
  • ENVIAgCalculateCropMetricsTask
  • ENVIAgRasterizeCropsTask

You can run ENVIAgCropCountTask or ENVIAgCountAndRasterizeCropsTask to create the ENVIAgCrops object that is required for this task. Or, you can use an ENVIAgCrops file that you created and saved earlier.

This task is part of ENVI Crop Science, which requires a separate license and installation.

Example


This example performs the following steps:

  1. Opens an orthophoto of a citrus orchard.
  2. Creates a spectral index raster to make the citrus trees bright against the background. A Modified Triangular Vegetation Index (MTVI) works well in this case and will be used for crop counting. This spectral index is unrelated to the one used to calculate crop metrics.
  3. Tip: See the ENVISpectralIndexRaster topic in ENVI Help for a list of spectral indices. You can run ENVIQuerySpectralIndicesTask to see what indices are available for your particular image.

  4. Runs ENVIAgCropCount to count the trees and to create an ENVIAgCrops object.
  5. Runs ENVIAgCalculateAndRasterizeCropMetricsWithSpectralIndex task, using a Normalized Difference Vegetation Index (NDVI) as the basis for calculating metrics.
  6. Displays a classification raster showing relative NDVI means of the citrus trees, overlaid on the orthophoto.
  7. Prints the range of NDVI values.
; Start the application
e = ENVI()
 
; Open a multispectral image
File = Filepath('CitrusOrthophoto.dat', $
  Subdir=['data','crop_science'], $
  Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
 
; Create a spectral index image to make the
; crops bright against a dark background.
MTVIImage = ENVISpectralIndexRaster(Raster, 'MTVI')
 
; Count the crops and output an ENVIAgCrops object
outCrops = ENVIAgCropCount(MTVIImage, 2.0, 5.0, $
  GAUSSIAN_FACTOR = 0, $
  /INCLUDE_EDGES, $
  INTENSITY_THRESHOLD = 0.8, $
  NUMBER_OF_INCREMENTS = 4, $
  PERCENT_OVERLAP = 100.0)
 
; Get the metrics task from the catalog of ENVITasks
Task = ENVITask('AgCalculateAndRasterizeCropMetricsWithSpectralIndex')
 
; Define inputs
Task.INPUT_RASTER = Raster ; Select the original multispectral image
Task.INDEX = 'Normalized Difference Vegetation Index'
Task.INPUT_CROPS = outCrops
 
; Define outputs
Task.OUTPUT_RASTER_URI = e.GetTemporaryFilename()
 
; Run the task
Task.Execute
 
; Get the collection of objects currently in the Data Manager
DataColl = e.Data
 
; Add the output to the data collection
DataColl.Add, Task.OUTPUT_RASTER
 
; Display the result
View = e.GetView()
Layer = View.CreateLayer(Raster)
Layer.Transparency = 25
Layer2 = View.CreateLayer(Task.OUTPUT_RASTER)
View.Zoom, /FULL_EXTENT
 
; Print the range of NDVI values
crops = Task.OUTPUT_CROPS
Print, 'Minimum NDVI value for entire image: ',MIN(crops.CROP_MIN)
Print, 'Maximum NDVI value for entire image: ',MAX(crops.CROP_MAX)

Syntax


Result = ENVITask('AgCalculateAndRasterizeCropMetricsWithSpectralIndex')

Input properties (Set, Get): CLASSIFICATION, INDEX, INPUT_CROPS, INPUT_RASTER, OUTPUT_CROPS_URI, OUTPUT_METRIC, OUTPUT_RASTER_URI

Output properties (Get only): DESCRIPTION, NAME, OUTPUT_CROPS, OUTPUT_RASTER

Properties marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Properties marked as "Get" are those whose values you can retrieve but not set.

Methods


This task inherits the following methods from ENVITask. See the ENVITask topic in ENVI Help.

  • AddParameter
  • Execute
  • Parameter
  • ParameterNames
  • RemoveParameters

Properties


CLASSIFICATION (optional)

Set this property to true (the default value) to create a classification raster where crops are colored according to relative means. For example, a dark green polygon corresponds to a crop with a higher mean value than light-green, yellow, and red polygons. The resulting raster will look similar to the following:

If you set the CLASSIFICATION property to false, the output will be a greyscale raster that is based on the actual mean values of the crops; for example:

DESCRIPTION

This property describes the task.

INDEX (required)

Specify a string indicating the spectral index from which to calculate crop metrics. See ENVISpectralIndexRaster for a full list of spectral indices. You can run ENVIQuerySpectralIndicesTask to see what indices are available for your particular image.

INPUT_CROPS (required)

Specify an input ENVIAgCrops object. You can run ENVIAgCropCountTask or ENVIAgCountAndRasterizeCropsTask to create an ENVIAgCrops object before running this task. Or, you can use an ENVIAgCrops file that you created and saved earlier.

INPUT_RASTER (required)

Specify a multispectral raster that will be used to create the specified spectral index raster.

NAME

This property contains the name of the task.

OUTPUT_CROPS

This is a reference to the output crop data.

OUTPUT_CROPS_URI (optional)

Specify a string with the fully qualified path and filename for OUTPUT_CROPS. If you do not specify this property, the output crop file is only temporary. Once the crop file has no remaining references, ENVI deletes the temporary file.

OUTPUT_METRIC (required)

Set this property to a string indicating the metric that the output raster will be based on. Currently the only option is Crop Mean. The means can be used for examining absolute characteristics of the crops.

OUTPUT_RASTER

This is a reference to the output crops classification raster or grayscale raster.

OUTPUT_RASTER_URI (optional)

Specify a string with the fully qualified filename and path of the output raster. If you do not specify this property, the output raster is only temporary. Once the raster has no remaining references, ENVI deletes the temporary file.

Version History


1.0

Introduced

See Also


ENVIAgCalculateCropMetricsTask, ENVIAgCalculateAndRasterizeCropMetricsTask, ENVIAgCrops, ENVIAgCropCountTask, ENVIAgCountAndRasterizeCropsTask



© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us