This task locates and counts crops in high-resolution, single-band images.

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 RGB image of emerging cotton plants, captured by an unmanned aerial vehicle (UAV). Image courtesy of Drone Global Network.
  2. Runs AgCropCount Task on the green band of the image, to count the crops and to create an ENVIAgCrops object.
  3. Prints the ENVIAgCrops object properties.
; 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])
 
; Get the task from the catalog of ENVITasks
Task = ENVITask('AgCropCount')
 
; Define inputs
Task.INPUT_RASTER = subset
Task.INCLUDE_EDGES ='true'
Task.MINIMUM_CROP_DIAMETER = 9 ;pixels
Task.MAXIMUM_CROP_DIAMETER = 12
Task.NUMBER_OF_INCREMENTS= 12
Task.GAUSSIAN_FACTOR = 0.8
Task.PERCENT_OVERLAP = 60
Task.INTENSITY_THRESHOLD = 0.81
 
; Run the task
Task.Execute
 
; Get the output ENVIAgCrops object
outCrops = Task.OUTPUT_CROPS
 
; Print the properties of the crop object
Print, outCrops

Syntax


Result = ENVITask('AgCropCount')

Input properties (Set, Get): GAUSSIAN_FACTOR, INCLUDE_EDGES, INPUT_RASTER, INTENSITY_THRESHOLD, MAXIMUM_CROP_DIAMETER, MINIMUM_CROP_DIAMETER, NUMBER_OF_INCREMENTS, OUTPUT_CROPS_URI, PERCENT_OVERLAP

Output properties (Get only):OUTPUT_CROPS, OUTPUT_NCROPS

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:

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. To disable Gaussian smoothing, set GAUSSIAN_FACTOR to 0.

INCLUDE_EDGES (optional)

Set this property to true to count partial crops touching the edges of the image or any masked area that surrounds the area to be counted. Also set it to true when applying a mask within the area being counted, for example, when masking out non-vegetation pixels. The default is false.

INPUT_RASTER (required)

Specify a single-band raster as input.

INTENSITY_THRESHOLD (optional)

Specify the fraction of the maximum crop intensity, below which crop detections will be removed.

MAXIMUM_CROP_DIAMETER (required)

Specify the maximum crop diameter. The diameter is measured in meters if the input raster has a standard spatial reference. Otherwise, specify the number of pixels for the diameter.

MINIMUM_CROP_DIAMETER (required)

Specify the minimum crop diameter. The diameter is measured in meters if the input raster has a standard spatial reference. Otherwise, specify the number of pixels for the diameter.

AgCropCount Task 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.

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

This is a reference to the output crop data.

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.

OUTPUT_NCROPS (optional)

This is a reference to the output number of crops.

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 the OUTPUT_NCROPS property

See Also


ENVIAgCrops, AgCountAndRasterizeCrops Task, AgCalculateCropMetrics Task