ENVIAgCalculateCropMetricsTask
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 ENVIAgCropCountTask or ENVIAgCountAndRasterizeCropsTask to create an ENVIAgCrops object before running ENVIAgCalculateCropMetricsTask. 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 ENVIAgCalculateAndRasterizeCropMetricsTask or ENVIAgCalculateAndRasterizeCropMetricsWithSpectralIndexTask.
This task is part of ENVI Crop Science, which requires a separate license and installation.
Example
This example performs the following steps:
- Opens an orthophoto of a citrus orchard.
- 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.
Tip: See the ENVISpectralIndexRaster topic in ENVI Help for a full list of spectral indices. You can run ENVIQuerySpectralIndicesTask to see what indices are available for your particular image.
- Runs ENVIAgCropCount to count the trees and to create an ENVIAgCrops object.
- Runs ENVIAgCalculateCropMetricsTask to calculate metrics from the NDVI image.
- Prints the NDVI metrics.
e = ENVI(/HEADLESS)
File = Filepath('CitrusOrthophoto.dat', $
Subdir=['data','crop_science'], $
Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
NDVIImage = ENVISpectralIndexRaster(Raster, 'NDVI')
outCrops = ENVIAgCropCount(NDVIImage, 2.0, 5.0, $
GAUSSIAN_FACTOR = 0, $
/INCLUDE_EDGES, $
INTENSITY_THRESHOLD = 0.8, $
NUMBER_OF_INCREMENTS = 4, $
PERCENT_OVERLAP = 100.0)
Task = ENVITask('AgCalculateCropMetrics')
Task.INPUT_CROPS = outCrops
Task.INPUT_RASTER = NDVIImage
Task.Execute
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 "Init" are applied only during the initial creation of the object. Properties marked as "Set" are those that you can set to specific values after the object has been created. 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
This task inherits the following properties from ENVITask:
COMMUTE_ON_DOWNSAMPLE
COMMUTE_ON_SUBSET
DESCRIPTION
DISPLAY_NAME
NAME
REVISION
See the ENVITask topic in ENVI Help for details.
This task also contains the following properties:
INPUT_CROPS (required)
Specify an input ENVIAgCrops object. You can run ENVIAgCropCountTask or ENVIAgCountAndRasterizeCropsTask to create an ENVIAgCrops object before running ENVIAgCalculateCropMetricsTask. 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
See Also
ENVIAgCrops, ENVIAgCropCountTask