AgCalculateAndRasterizeZoneMetricsWithSpectralIndex Task
This task creates a spectral index image and calculates statistics from it and an associated ENVIAgZones object. It creates a classification raster showing the relative statistics of the zones or a grayscale raster showing the actual statistical values of the zones.
AgCalculateAndRasterizeZoneMetricsWithSpectralIndex Task is a metatask that automatically runs the following tasks:
This task requires a separate license for the ENVI Crop Science Module; contact your sales representative for more information.
Example
This example:
- Opens a hyperspectral raster.
- Creates a Moisture Stress Index raster from the hyperspectral raster.
- Runs AgCreateZones Task to create zones from the Moisture Stress Index raster.
- Runs AgCalculateAndRasterizeZoneMetricsWithSpectralIndex Task using the hyperspectral image as input.
- Computes mean Normalized Difference Vegetation Index (NDVI) values for each zone.
- Displays a classification image showing the relative NDVI means for each zone.
The hyperspectral source data were provided by the National Ecological Observatory Network (NEON). The hyperspectral image was previously subsetted and masked to include a single agricultural field.
; Start the application
e = ENVI()
; Open a hyperspectral image
File = Filepath('NEONHyperspectral1m.dat', $
Subdir=['data','crop_science'], $
Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
; Create a Moisture Stress Index raster
indexTask = ENVITask('SpectralIndex')
indexTask.INPUT_RASTER = Raster
indexTask.INDEX = 'Moisture Stress Index'
indexTask.Execute
MSIRaster = indexTask.OUTPUT_RASTER
; Create a zones object from the Moisture
; Stress Index raster
zonesTask = ENVITask('AgCreateZones')
zonesTask.INPUT_RASTER = MSIRaster
zonesTask.MINIMUM_AREA = 1000
zonesTask.NUMBER_OF_APPLICATION_CATEGORIES = 4
zonesTask.Execute
; Calculate zone metrics using NDVI from the
; hyperspectral image
Task = ENVITask('AgCalculateAndRasterizeZoneMetricsWithSpectralIndex')
Task.INPUT_RASTER = Raster
Task.INDEX = 'Normalized Difference Vegetation Index'
Task.CLASSIFICATION = 'true'
Task.INPUT_ZONES = zonesTask.OUTPUT_ZONES
Task.INPUT_ZONE_RASTER = zonesTask.OUTPUT_RASTER
Task.Execute
; 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(MSIRaster)
Layer2 = View.CreateLayer(Task.OUTPUT_RASTER)
View.Zoom, 3.0
Syntax
Result = ENVITask('AgCalculateAndRasterizeZoneMetricsWithSpectralIndex')
Input properties (Set, Get): CLASSIFICATION, INDEX, INPUT_RASTER, INPUT_ZONE_RASTER, INPUT_ZONES, OUTPUT_METRIC, OUTPUT_RASTER_URI, OUTPUT_ZONES_URI
Output properties (Get only): OUTPUT_RASTER, OUTPUT_ZONES
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.
Methods
This task inherits the following methods from ENVITask:
Properties
This task inherits the following properties from ENVITask:
This task also contains the following properties:
CLASSIFICATION (optional)
Set this property to true
to create a classification image showing the relative pattern of a selected zone metric. The default value is false
, which will create a grayscale image with the actual values of a zone metric.
INDEX (required)
Specify a string indicating the spectral index from which to calculate zone metrics. See SpectralIndex Task for a list of spectral indices. You can also run QuerySpectralIndices Task to see what indices are available for your particular image.
INPUT_RASTER (required)
Specify a multispectral raster from which zone metrics will be computed.
INPUT_ZONE_RASTER (optional)
Specify the zone classification raster that corresponds to the input zones. It allows metrics to be calculated faster for large images.
INPUT_ZONES (required)
Specify an input ENVIAgZones object.
OUTPUT_METRIC (optional)
Specify one of the following strings, indicating the metric that the output raster will be based on.
Zone Mean
(default)Zone Maximum
Zone Minimum
Zone Standard Deviation
OUTPUT_RASTER
This is a reference to the output zones classification raster or grayscale raster.
OUTPUT_RASTER_URI (optional)
Specify a string with the fully qualified filename and path of the associated OUTPUT_RASTER. If you do not specify this property, or set it to an exclamation symbol (!), a temporary file will be created.
OUTPUT_ZONES (required)
This is a reference to the output zones data.
OUTPUT_ZONES_URI (optional)
Specify a string with the fully qualified filename and path for the output .sav
file that will contain the zones data.
Version History
Crop Science 1.1 |
Introduced |
Crop Science 1.1.1 |
Added INPUT_ZONE_RASTER property |
See Also
ENVIAgZones, AgCreateZones Task, AgCalculateAndRasterizeZoneMetrics Task, AgCalculateZoneMetrics Task, AgRasterizeZones Task, AgConvertZonesToShapefile Task