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 parameters (Set, Get): INPUT_CROPS, INPUT_RASTER, OUTPUT_CROPS_URI

Output parameters (Get only): OUTPUT_CROPS

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

Input Parameters


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_URI (optional)

Specify a string with the fully qualified filename and path for the output JSON file that will contain the crop data.

Output Parameters


OUTPUT_CROPS

This is a reference to the output crop data. In addition to the standard ENVIAgCrops properties, the object will contain the following properties (with statistics):

  • 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

Methods


Execute

Parameter

ParameterNames

Properties


DESCRIPTION

DISPLAY_NAME

NAME

REVISION

TAGS

Version History


Crop Science 1.0

Introduced

See Also


ENVIAgCrops, AgCropCount Task