Welcome to the Harris Geospatial documentation center. Here you will find reference guides and help documents.

  >  Docs Center  >  Crop Science API  >  ENVIAgRasterizeCropsTask



This task creates a classification raster from an ENVIAgCrops object. The Crops class consists of circle outlines at the crop locations.

This task is part of ENVI Crop Science, which requires a separate license and installation.


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 ENVIAgCropCount on the green band to count the crops and to create an ENVIAgCrops object.
  3. Creates a classification raster showing the locations of the crops.
  4. Displays the classification raster over the green band of the source image.

Note: The resulting crop count includes several outliers. You can use ENVIAgFindRowsAndRemoveOutliersTask to remove these.

; Start the application
e = ENVI()
; Open an input file
File = Filepath('Cotton.dat', $
  SUBDIR=['data','crop_science'], $
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, $
  OUTPUT_NCROPS=outputNumCrops, $
; Get the rasterize task from the catalog of ENVITasks
Task = ENVITask('AgRasterizeCrops')
; Define the task inputs
Task.CROPS = outCrops
Task.FILLED = 'true'
; Run the task
; Get the collection of objects currently in the Data Manager
DataColl = e.Data
; Add the output to the data collection
DataColl.Add, Task.OUTPUT_RASTER
; Display the result
View = e.GetView()
Layer = View.CreateLayer(subset)
Layer2 = View.CreateLayer(Task.OUTPUT_RASTER)


Result = ENVITask('AgRasterizeCrops')


Output properties (Get only): OUTPUT_RASTER

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.


This task inherits the following methods from ENVITask. See the ENVITask topic in ENVI Help.

  • AddParameter
  • Execute
  • Parameter
  • ParameterNames
  • RemoveParameters


This task inherits the following properties from ENVITask:







See the ENVITask topic in ENVI Help for details.

This task also contains the following properties:


Set this property to true (the default value) to create a classification raster where crops are colored according to relative means. For example, a dark green polygon corresponds to a crop with a higher mean value than light-green, yellow, and red polygons. The resulting raster will look similar to the following:

If you set the CLASSIFICATION property to false, the output will be a greyscale raster that is based on the actual mean values of the crops; for example:

This property is ignored if you set OUTPUT_METRIC to Count.

CROPS (required)

Specify an input ENVIAgCrops object.

FILLED (optional)

Set this property to true to create filled circles. The default is false.

OUTPUT_METRIC (optional)

Specify one of the following strings indicating the metric or count that the output raster will be based on. The default is Count.

  • Count
  • Crop Minimum
  • Crop Maximum
  • Crop Mean
  • Crop Standard Deviation
  • Radius


This is a reference to the output crops classification raster.


Specify a string with the fully qualified filename and path of the output raster. If you do not specify this property, the output raster is only temporary. Once the raster has no remaining references, ENVI deletes the temporary file.

Version History




Radius was added as an option to OUTPUT_METRIC.

See Also

ENVIAgCropCount, ENVIAgCropCountTask, ENVIAgCountAndRasterizeCropsTask, ENVIAgCalculateCropMetrics, ENVIAgCalculateCropMetricsTask

© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us