AgCountAndRasterizeCrops Task
This task counts crops in a single-band input image and creates a classification raster with their locations and sizes. This is a metatask that runs the following tasks:
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:
- Opens an RGB image of emerging cotton plants, captured by an unmanned aerial vehicle (UAV). Image courtesy of Drone Global Network.
- Runs AgCountAndRasterizeCrops Task on the green band of the image, to count the crops and to create an ENVIAgCrops object.
- Prints the number of crops.
- Displays the classification raster over the green band of the source image.
; Start the application
e = ENVI()
; 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('AgCountAndRasterizeCrops')
; Define inputs
Task.INPUT_RASTER = subset
Task.FILLED ='true'
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 number of crops
Print, 'Number of crops: ',Task.OUTPUT_NCROPS
; Display the result
View = e.GetView()
Layer1 = View.CreateLayer(Raster)
Layer2 = View.CreateLayer(Task.OUTPUT_RASTER)
View.Zoom, /FULL_EXTENT
Syntax
Result = ENVITask('AgCountAndRasterizeCrops')
Input properties (Set, Get): FILLED, GAUSSIAN_FACTOR, INCLUDE_EDGES, INPUT_RASTER, INTENSITY_THRESHOLD, MAXIMUM_CROP_DIAMETER, MINIMUM_CROP_DIAMETER, NUMBER_OF_INCREMENTS, OUTPUT_CROPS_URI, OUTPUT_RASTER_URI, PERCENT_OVERLAP
Output properties (Get only): OUTPUT_CROPS, OUTPUT_NCROPS, OUTPUT_RASTER
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:
Properties
This task inherits the following properties from ENVITask:
This task also contains the following properties:
FILLED (optional)
Set this property to true
to create filled circles in the output crops classification raster. The default is false
.
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. The default value is 0.5.
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, preferably from an unmanned aerial vehicle (UAV) or high-resolution satellite image.
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.
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.
OUTPUT_RASTER
This is a reference to the output crops classification raster.
OUTPUT_RASTER_URI (optional)
Specify a string with the fully qualified filename and path of the associated OUTPUT_RASTER. If you do not specify this property, or set it to an exclamation symbol (!), a temporary file will be created.
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 property |
See Also
AgCropCount Task, AgRasterizeCrops Task, AgCalculateCropMetrics Task