AgEnhanceCrops Task
This task is a preprocessing step that enhances crops in a single-band raster. The result can be passed to ENVIAgCropCount or AgCountAndRasterizeCrops Task. You can optionally set minimum and maximum pixel value thresholds on the input raster. The task then inverts the remaining pixel values, unless you choose to disable inversion.
This task requires a separate license for the ENVI Crop Science Module; contact your sales representative for more information.
Example
This example performs the following steps:
- Opens an orthophoto of a citrus orchard.
- Creates a spectral subset consisting of the green band only.
- Masks out pixel values greater than 90 in the green band. These are primarily soil pixels that need to be masked out.
- Inverts the thresholded green band image to make the citrus trees appear bright.
- Displays the result.
; Start the application
e = ENVI()
; Open an input file
File = Filepath('CitrusOrthophoto.dat', $
Subdir=['data','crop_science'], $
Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
; Define a spectral subset consisting of
; the green band
GreenBand = ENVISubsetRaster(Raster, BANDS=1)
; Get the task from the catalog of ENVITasks
Task = ENVITask('AgEnhanceCrops')
; Define task inputs
Task.INPUT_RASTER = GreenBand
Task.INPUT_MAX = 90 ; to mask out bright soil pixels
Task.INVERSE='true'
; Run the task
Task.Execute
; Get the collection of objects currently 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)
The resulting image still contains shadows, which have a similar brightness to the citrus trees in the inverted green band. It is difficult to remove these pixels without also removing vegetation pixels. See More Examples for a different method of isolating the citrus trees.
Syntax
Result = ENVITask('AgEnhanceCrops')
Input properties (Set, Get): INPUT_MAX, INPUT_MIN, INPUT_RASTER, INVERSE, OUTPUT_RASTER_URI
Output properties (Get only): OUTPUT_RASTER
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:
INPUT_MAX (optional)
Specify a maximum data value. Pixels greater than this value are set to NaN and will be ignored in subsequent processing. An example is setting a maximum value to remove shadows or bright soil pixels in an inverted green band image. These features have a similar brightness value to healthy vegetation and should be removed to reduce confusion in crop-counting tasks.
INPUT_MIN (optional)
Specify a minimum data value. Pixels less than this value are set to NaN and will be ignored in subsequent processing. An example is setting a mimimum value to remove dark shadows from a spectral index image (such as NDVI) or from a single-band image where INVERSE = 'false'
.
INPUT_RASTER (required)
Specify a single-band raster. If you have a multispectral dataset, you must create a spectral subset consisting of only one band.
INVERSE (optional)
Set this property to true
(the default value) to invert the data. An example is to invert the values in a green band.
OUTPUT_RASTER
This is a reference to the output raster of filetype ENVI.
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.
More Examples
This example performs the following steps:
- Opens an orthophoto of a citrus orchard.
- Creates an Iron Oxide spectral index image to highlight soil pixels.
- Masks out pixel values greater than 1.092. These are primarily soil pixels.
- Masks out pixel values lower than 0.322. These are primarily shadow pixels.
- Inverts the thresholded Iron Oxide image to make the citrus trees appear bright.
- Displays the result.
; Start the application
e = ENVI()
; Open an input file
File = Filepath('CitrusOrthophoto.dat', $
Subdir=['data','crop_science'], $
Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
; Create an Iron Oxide spectral index raster
indexRaster = ENVISpectralIndexRaster(Raster, 'Iron Oxide')
; Get the task from the catalog of ENVITasks
Task = ENVITask('AgEnhanceCrops')
; Define task inputs
Task.INPUT_RASTER = indexRaster
Task.INPUT_MIN = 0.322
Task.INPUT_MAX = 1.092
Task.INVERSE = 'true'
; Define outputs
Task.OUTPUT_RASTER_URI = e.GetTemporaryFilename()
; Run the task
Task.Execute
; Get the collection of objects currently 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)
Version History
Crop Science 1.0 |
Introduced |
See Also
ENVIAgEnhanceCrops, ENVIAgCrops, ENVIAgCropCount, AgCropCount Task, ENVIAgCalculateCropMetrics, AgCalculateCropMetrics Task, AgCalculateAndRasterizeCropMetrics Task, AgCalculateAndRasterizeCropMetricsWithSpectralIndex Task, AgCountAndRasterizeCrops Task, AgRasterizeCrops Task