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

Harris Geospatial / Docs Center / ENVI API / Crop Science / ENVIAgCropsToShapefileTask



This task 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 orthophoto of a citrus orchard.
  2. Creates a spectral index raster to make the citrus trees bright against the background. A Modified Triangular Vegetation Index (MTVI) works well in this case.
  3. Tip: See the ENVISpectralIndexRaster topic in ENVI Help for a list of spectral indices. Or, run ENVIQuerySpectralIndicesTask first to see what indices are available for your particular image.

  4. Runs ENVIAgCropCount to count the trees and to create an ENVIAgCrops object.
  5. Creates a shapefile from the ENVIAgCrops object.
  6. Displays the shapefile on top of the orthophoto.
; Start the application
e = ENVI()
; Open an input file
File = Filepath('CitrusOrthophoto.dat', $
  Subdir=['data','crop_science'], $
Raster = e.OpenRaster(File)
; Preprocess the image so that crops are bright.
MTVIImage = ENVISpectralIndexRaster(Raster, 'MTVI')
; Count the crops and create an ENVIAgCrops object
outCrops = ENVIAgCropCount(MTVIImage, 2.0, 5.0, $
; Get the crops-to-shapefile task from the 
; catalog of ENVITasks
task = ENVITask('AgCropsToShapefile')
; Define inputs
task.INPUT_CROPS = outCrops
; Define outputs
task.OUTPUT_VECTOR_URI = e.GetTemporaryFilename('.shp')
; Run the task
; Display the result
View = e.GetView()
Layer = View.CreateLayer(Raster)
Layer2 = View.CreateLayer(task.OUTPUT_VECTOR)


Result = ENVITask('AgCropsToShapefile')

Input properties (Set, Get): INPUT_CROPS, OUTPUT_VECTOR_URI

Output properties (Get only): DESCRIPTION, NAME, OUTPUT_VECTOR

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.


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

  • AddParameter
  • Execute
  • Parameter
  • ParameterNames
  • RemoveParameters



This property describes the task.

INPUT_CROPS (required)

Specify an input ENVIAgCrops object.


This property contains the name of the task.


This is a reference to the output vector.


Specify a string with the fully qualified path and filename for the output ENVIVector.

Version History



See Also

ENVIAgCropsToShapefile, ENVIAgCrops, ENVIAgCropCount, ENVIAgCropCountTask

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