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.
e = ENVI()
File = Filepath('Cotton.dat', $
SUBDIR=['data','crop_science'], $
ROOT_DIR=e.Root_Dir)
Raster = e.OpenRaster(File)
subset = ENVISubsetRaster(Raster, BANDS=[1])
Task = ENVITask('AgCountAndRasterizeCrops')
Task.INPUT_RASTER = subset
Task.FILLED ='true'
Task.INCLUDE_EDGES ='true'
Task.MINIMUM_CROP_DIAMETER = 9
Task.MAXIMUM_CROP_DIAMETER = 12
Task.NUMBER_OF_INCREMENTS= 12
Task.GAUSSIAN_FACTOR = 0.8
Task.PERCENT_OVERLAP = 60
Task.INTENSITY_THRESHOLD = 0.81
Task.Execute
outCrops = Task.OUTPUT_CROPS
Print, 'Number of crops: ',Task.OUTPUT_NCROPS
View = e.GetView()
Layer1 = View.CreateLayer(Raster)
Layer2 = View.CreateLayer(Task.OUTPUT_RASTER)
View.Zoom, /FULL_EXTENT
Syntax
Result = ENVITask('AgCountAndRasterizeCrops')
Input parameters (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 parameters (Get only): OUTPUT_CROPS, OUTPUT_NCROPS, OUTPUT_RASTER
Parameters marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Parameters marked as "Get" are those whose values you can retrieve but not set.
Input Parameters
FILLED (optional)
Set this parameter 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 parameter 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 parameter 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_URI (optional)
Specify a string with the fully qualified filename and path for the output JSON file that will contain the crop data.
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 parameter, or set it to an exclamation symbol (!), ENVI creates a temporary file.
- If you set it to the hash symbol (#), ENVI creates a file in the temporary directory, but this file will not be deleted when ENVI closes.
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.
Output Parameters
OUTPUT_CROPS
This is a reference to the output crop data.
OUTPUT_NCROPS
This is a reference to the output number of crops.
OUTPUT_RASTER
This is a reference to the output crops classification raster.
Methods
Execute
Parameter
ParameterNames
Properties
DESCRIPTION
DISPLAY_NAME
NAME
REVISION
TAGS
Version History
Crop Science 1.0
|
Introduced |
Crop Science 1.0.1
|
Added OUTPUT_NCROPS parameter
|
See Also
AgCropCount Task, AgRasterizeCrops Task, AgCalculateCropMetrics Task