>  Docs Center  >  Crop Science API  >  ENVIAgHotspotAnalysisTask



This task runs hotspot analysis on a single-band raster to look for areas that are statistically significant from surrounding areas. The resulting image shows the most significant features for the image.

The difference between this task and ENVIAgSpectralHotspotAnalysis is that you can pass in any single-band raster, not just a spectral index.

ENVIAgHotspotAnalysisTask is a metatask that runs the following tasks:

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


This example creates a hotspot image that shows the relative health of alfalfa crops.

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 calculate a Modified Simple Ratio index. You do not necessarily have to use a spectral index image; you can pass in any single-band raster.

; 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 collection of tasks
Task = ENVITask('AgHotspotAnalysis')
; Define task inputs
Task.DISTANCE = 10 ; meters
; 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(Raster)
Layer2 = View.CreateLayer(Task.OUTPUT_RASTER)
View.Zoom, 0.75


Result = ENVITask('AgHotspotAnalysis')


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:

DISTANCE (required)

Specify the radius of the area around each pixel used to calculate the local mean. If the input raster has a valid spatial reference, then the radius is measured in meters. Otherwise, it is measured in pixels.

INPUT_RASTER (required)

Specify a single-band input raster.


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

ENVIAgSpectralHotspotAnalysisTask, ENVIAgHotspotColorSliceTask, ENVIAgCalculateGetisOrdTask

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