ENVIAgCropCount
This function locates and counts crops in high-resolution, single-band images.
This object is part of ENVI Crop Science, which requires a separate license and installation.
Example
This example performs the following steps:
- Opens an RGB image of emerging cotton plants, captured by an unmanned aerial vehicle (UAV). Image courtesy of Drone Global Network.
- Runs ENVIAgCropCount on the green band of the image, to count the crops and to create an ENVIAgCrops object.
- Prints the ENVIAgCrops object properties.
Note: The resulting crop count includes several outliers. You can use AgFindRowsAndRemoveOutliers Task to remove these.
; Start the application
e = ENVI(/HEADLESS)
; Open an input file
File = Filepath('Cotton.dat', $
SUBDIR=['data','crop_science'], $
ROOT_DIR=e.Root_Dir)
Raster = e.OpenRaster(File)
; Process the green band
subset = ENVISubsetRaster(Raster, BANDS=[1])
; Count the crops and output an ENVIAgCrops object
outCrops = ENVIAgCropCount(subset, 9, 12, $
GAUSSIAN_FACTOR=0.8, $
/INCLUDE_EDGES, $
INTENSITY_THRESHOLD=0.81, $
NUMBER_OF_INCREMENTS=12, $
OUTPUT_NCROPS=outputNumCrops, $
PERCENT_OVERLAP=60)
; Print the crop count
Print, outputNumCrops
Result:
554
Syntax
Result = ENVIAgCropCount(Input_Raster, Minimum_Crop_Diameter, Maximum_Crop_Diameter [, Keywords=value])
Return Value
This function returns a reference to an ENVIAgCrops object.
Arguments
Input_Raster
Specify a single-band ENVIRaster object.
Minimum_Crop_Diameter
Specify the minimum crop diameter. The diameter is measured in meters if the input raster has a spatial reference. Otherwise, specify the number of pixels for the diameter.
ENVIAgCropCount works best when the minimum and maximum crop diameters do not differ greatly in size. For example, a range of 1 to 4 meters will produce better results than a range of 1 to 16 meters. If your area of interest has a wide range of crop diameters, consider splitting up the area into separate images to process, each with a similar range of crop diameters.
Maximum_Crop_Diameter
Specify the maximum crop diameter. The diameter is measured in meters if the input raster has a spatial reference. Otherwise, specify the number of pixels for the diameter.
Methods
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.
GAUSSIAN_FACTOR (optional)
Specify a Gaussian smoothing factor to use before searching for crops. This is the fraction of the maximum search diameter at which smoothing should occur. The default value is 0.5. To disable Gaussian smoothing, set GAUSSIAN_FACTOR to 0.
INCLUDE_EDGES (optional)
Set this property to include crops that are touching or are very close to image and mask edges.
INTENSITY_THRESHOLD (optional)
Specify the fraction of the maximum crop intensity, below which crop detections will be removed.
NUMBER_OF_INCREMENTS (optional)
Specify the number of increments to use when searching crops. Use this property in conjunction with MAXIMUM_CROP_DIAMETER and MINIMUM_CROP_DIAMETER. The number of increments includes the minimum and maximum diameters. The default value is 5. For example, if the minimum crop diameter is 1 meter and the maximum crop diameter is 5 meters, setting the number of increments to 5 will search for crops of exactly 1, 2, 3, 4, and 5 meters.
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.
OUTPUT_NCROPS (optional)
Specify a variable name that will contain the number of crops that were counted.
PERCENT_OVERLAP (optional)
Specify the percentage of allowable overlap between crops before one of them is removed from consideration. The default value is 50.0. To disable the overlapping percentage, set PERCENT_OVERLAP to 100. To allow no overlapping at all, set PERCENT_OVERLAP to 0. Enter smaller values if the crops are distinctly separated from one another.
Version History
Crop Science 1.0 |
Introduced |
Crop Science 1.0.1 |
Added OUTPUT_NCROPS keyword |