This function 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 ENVIAgCropCount or AgCountAndRasterizeCrops Task to create an ENVIAgCrops object before running ENVIAgCalculateCropMetrics. 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 object 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 Normalized Difference Vegetation Index (NDVI) works well in this case.
  3. Tip: See SpectralIndex Task for a complete list of spectral indices. You can run QuerySpectralIndices Task to see what indices are available for your particular image.

  4. Uses the AgCropCount function to count the trees and to create an ENVIAgCrops object.
  5. Uses the AgCalculateCropMetrics function 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)
 
; Calculate crop metrics
outCropMetrics = ENVIAgCalculateCropMetrics(NDVIImage, outCrops)
 
; Print the crop metrics
Print, outCropMetrics

Syntax


Result = ENVIAgCalculateCropMetrics(Input_Raster, Input_Crops [, Keywords=value])

Return Value


This function returns a reference to an ENVIAgCrops object.

Arguments


Input_Raster

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

Input_Crops

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

Methods


Dehydrate

Export

Hydrate

Properties


The output ENVIAgCrops object contains the following properties, in addition to the standard ENVIAgCrops properties:

CROP_MAX (Get)

The maximum pixel value for each crop.

CROP_MEAN (Get)

The mean pixel value for each crop.

CROP_MIN (Get)

The minimum pixel value for each crop.

CROP_STDDEV (Get)

The standard deviation pixel value for each crop.

Keywords


ERROR (optional)

Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.

OUTPUT_CROPS_FILENAME (optional)

Specify a string with a fully qualified filename and path, to save an ENVIAgCrops object to a JSON-formatted text file.

Version History


Crop Science 1.0

Introduced

See Also


AgCalculateCropMetrics Task, ENVIAgCrops, ENVICropCount, AgCalculateAndRasterizeCropMetrics Task, AgCalculateAndRasterizeCropMetricsWithSpectralIndex Task