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 / ENVIAgCalculateGetisOrdTask



This task creates a Z-score raster to find regions that are statistically significant.

ENVI calculates Getis-Ord Gi* local statistics (Getis and Ord, 1992) to group neighboring pixels of similar value into clusters. The algorithm evaluates each pixel and its surrounding pixels within a specified distance to classify the pixel as "hot" or "cold" (statistically significant clusters of high or low values, respectively) or neutral (not statistically significant). Hotspot analysis can be used to look for variations in crop health.

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


This example creates a Z-score raster from a spectral index image of alfalfa fields.

The source image consists of layer-stacked Sentinel-2A visible, near-infrared, and shortwave-infrared bands with a spatial resolution of 10 meters. The image is from eastern Idaho, USA. The accompanying region of interest (ROI) file encompasses alfalfa fields. It is used to mask out all non-alfalfa pixels from the source image. The masked raster is then used to create a Modified Simple Ratio index, which is used as input to ENVIAgCalculateGetisOrdTask.

; Start the application
e = ENVI()
; Open an input file
File = Filepath('CircularFields_Sentinel2A.dat', $
  Subdir=['data', 'crop_science'], $
Raster = e.OpenRaster(File)
; Only process the actively growing fields
; using an ROI mask
ROIFile = Filepath('CircularFields_AlfalfaROI.xml', $
  Subdir=['data', 'crop_science'], $
ROI = e.OpenROI(ROIFile)
maskedRaster = ENVIROIMaskRaster(Raster, ROI)
; Create a Modified Simple Ratio index
MSRImage = ENVISpectralIndexRaster(maskedRaster, 'MSR')
; Get the task from the catalog of ENVITasks
Task = ENVITask('AgCalculateGetisOrd')
; Define the task inputs
Task.DISTANCE = 10 ; meters
; Define task outputs
Task.OUTPUT_RASTER_URI = e.GetTemporaryFilename()
; Run the task
; Get the collection of data objects currently 
; available in the Data Manager
DataColl = e.Data
; Add the output to the Data Manager
DataColl.Add, Task.OUTPUT_RASTER
; Display the result
View = e.GetView()
Layer = View.CreateLayer(Task.OUTPUT_RASTER)
Layer.QUICK_STRETCH = 'Equalization'


Result = ENVITask('AgCalculateGetisOrd')


Output Properties (Get Only): DESCRIPTION, NAME, OUTPUT_RASTER


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.

DISTANCE (required)

Specify the search distance. If the input raster has a standard spatial reference, then distance is measured in meters. Otherwise, it is measured in pixels.

INPUT_RASTER (required)

Specify a single-band input raster.


This property contains the name of the task.


This is a reference to the output raster of filetype ENVI.


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



See Also

ENVIAgHotspotColorSliceTask, ENVIAgSpectralHotspotAnalysisTask

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