This function converts an ENVIAgCrops object to a shapefile.

This object 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 of the image, to count the crops and to create an ENVIAgCrops object.
  3. Creates a shapefile from the ENVIAgCrops object.
  4. Displays the shapefile on top of the image.

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

; Start the application
; 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, $
; Create a shapefile of the crops object
outVector = ENVIAgCropsToShapefile(outCrops)


Result = ENVIAgCropsToShapefile(Input_Crops [, Keywords=value])

Return Value

This function returns a reference to an ENVIVector object.



Specify an input ENVIAgCrops object.


This function inherits the following methods from ENVIVector.

  • Close
  • Dehydrate
  • Hydrate


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.


Specify a string with a fully qualified path and filename for the output ENVIVector object. If you do not set this keyword, an output file will be automatically created.

Version History

Crop Science 1.0


See Also

AgCropsToShapefile Task, ENVIAgCrops, ENVIAgCropCount, AgCropCount Task