This task calculates statistics from a raster and an associated ENVIAgCrops object. For example, if the input raster is a vegetation index such as NDVI, the crop metrics describe the health of the crops. You can run AgCropCount Task or AgCountAndRasterizeCrops Task to create an ENVIAgCrops object before running AgCalculateCropMetrics Task. Or, you can use an ENVIAgCrops file that you created and saved earlier.

To create a raster that you can visualize from crop metrics, use AgCalculateAndRasterizeCropMetrics Task or AgCalculateAndRasterizeCropMetricsWithSpectralIndex Task.

This task requires a separate license for the ENVI Crop Science Module; contact your sales representative for more information.

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 Normalized Difference Vegetation Index (NDVI) works well in this case.
  3. Tip: See SpectralIndex Task for a list of spectral indices. You can run QuerySpectralIndices Task 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 AgCalculateCropMetrics Task to calculate metrics from the NDVI image.
  6. Prints the NDVI metrics.
; Start the application
e = ENVI(/HEADLESS)
 
; Open an input file
File = Filepath('CitrusOrthophoto.dat', $
  Subdir=['data','crop_science'], $
  Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
 
; Preprocess the image so that crops are bright.
NDVIImage = ENVISpectralIndexRaster(Raster, 'NDVI')
 
; Count the crops and output an ENVIAgCrops object
outCrops = ENVIAgCropCount(NDVIImage, 2.0, 5.0, $
  GAUSSIAN_FACTOR = 0, $
  /INCLUDE_EDGES, $
  INTENSITY_THRESHOLD = 0.8, $
  NUMBER_OF_INCREMENTS = 4, $
  PERCENT_OVERLAP = 100.0)
 
; Run the crop metrics task
Task = ENVITask('AgCalculateCropMetrics')
Task.INPUT_CROPS = outCrops
Task.INPUT_RASTER = NDVIImage
Task.Execute
 
; Print the crop metrics
outCropMetrics = Task.OUTPUT_CROPS
Print, outCropMetrics

Syntax


Result = ENVITask('AgCalculateCropMetrics')

Input properties (Set, Get): INPUT_CROPS, INPUT_RASTER, OUTPUT_CROPS_URI

Output properties (Get only): OUTPUT_CROPS

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:

AddParameter

Execute

Parameter

ParameterNames

RemoveParameter

Properties


This task inherits the following properties from ENVITask:

COMMUTE_ON_DOWNSAMPLE

COMMUTE_ON_SUBSET

DESCRIPTION

DISPLAY_NAME

NAME

REVISION

TAGS

This task also contains the following properties:

INPUT_CROPS (required)

Specify an input ENVIAgCrops object. You can run AgCropCount Task or AgCountAndRasterizeCrops Task to create an ENVIAgCrops object before running AgCalculateCropMetrics Task. Or, you can use an ENVIAgCrops file that you created and saved earlier.

INPUT_RASTER (required)

Specify a single-band input raster. With multispectral images, you must first create a single-band spectral subset.

OUTPUT_CROPS

This is a reference to the output crop data, which contains extra properties (with statistics) in addition to the standard ENVIAgCrops properties:

  • CROP_MAX: The maximum pixel value for each crop
  • CROP_MEAN: The mean pixel value for each crop
  • CROP_MIN: The minimum pixel value for each crop
  • CROP_STDDEV: The standard deviation pixel value for each crop

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.

Version History


Crop Science 1.0

Introduced

See Also


ENVIAgCrops, AgCropCount Task