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

ENVIAgFindRowsAndRemoveOutliersTask

ENVIAgFindRowsAndRemoveOutliersTask

This task finds rows within an ENVIAgCrops object, removes crops that are outside the rows, and creates a classification raster with the remaining crop locations and sizes. It optionally creates polyline and polygon regions of interest (ROIs) centered over each row. You must run ENVIAgCropCount, ENVIAgCropCountTask, or ENVIAgCountAndRasterizeCropsTask first before running this task.

Example


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 Normalized Difference Vegetation Index (NDVI) works well in this case.
  3. Tip: See the ENVISpectralIndexRaster topic in ENVI Help for a list of spectral indices. You can run ENVIQuerySpectralIndicesTask to see what indices are available for your particular image.

  4. Runs ENVIAgCountAndRasterizeCropsTask to count the trees and to create an ENVIAgCrops object.
  5. Runs ENVIAgFindRowsAndRemoveOutliersTask.
  6. Displays the input orthophoto, the crops raster (with outliers removed), and the row polyline ROI.
; 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)
 
; Preprocess the image so that crops are bright.
NDVIImage = ENVISpectralIndexRaster(Raster, 'NDVI')
 
; Count and rasterize the crops
CropCountTask = ENVITask('AgCountAndRasterizeCrops')
CropCountTask.INPUT_RASTER = NDVIImage
CropCountTask.FILLED = 'true'
CropCountTask.INCLUDE_EDGES = 'true'
CropCountTask.MINIMUM_CROP_DIAMETER = 2.0 ; meters
CropCountTask.MAXIMUM_CROP_DIAMETER = 5.0
CropCountTask.NUMBER_OF_INCREMENTS = 4
CropCountTask.GAUSSIAN_FACTOR = 0
CropCountTask.PERCENT_OVERLAP = 20.0
CropCountTask.INTENSITY_THRESHOLD = 0.8
CropCountTask.OUTPUT_CROPS_URI = e.GetTemporaryFilename('json')
CropCountTask.Execute
 
; Find rows and remove outliers
Task = ENVITask('AgFindRowsAndRemoveOutliers')
Task.INPUT_CROPS = CropCountTask.OUTPUT_CROPS
Task.DISTANCE_THRESHOLD = 1.2
Task.FILLED = 'true'
Task.Execute
 
; Display the result
View = e.GetView()
Layer1 = View.CreateLayer(Raster)
Layer2 = View.CreateLayer(Task.OUTPUT_RASTER)
roiLayer = Layer2.AddROI(Task.OUTPUT_ROIS[0])
 
Print, 'Number of outliers removed: ', Task.OUTPUT_NREMOVED
Print, 'Number of rows found: ', Task.OUTPUT_NROWS

Syntax


Result = ENVITask('AgFindRowsAndRemoveOutliers')

Input properties (Set, Get): DISTANCE_THRESHOLD, FILLED, INLIER_FRACTION, INPUT_CROPS, MAXIMUM_SLOPE, MINIMUM_CROPS_PER_ROW, OUTPUT_CROPS_URI, OUTPUT_RASTER_URI, OUTPUT_REMOVED_CROPS_URI, OUTPUT_ROWS_ROIS_URI

Output properties (Get only): DESCRIPTION, NAME, OUTPUT_CROPS, OUTPUT_NCROPS, OUTPUT_NREMOVED, OUTPUT_NROWS, OUTPUT_RASTER, OUTPUT_REMOVED_CROPS, OUTPUT_ROW_ROIS

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. See the ENVITask topic in ENVI Help.

  • AddParameter
  • Execute
  • Parameter
  • ParameterNames
  • RemoveParameters

Properties


DESCRIPTION

This property describes the task.

DISTANCE_THRESHOLD (optional)

Specify a distance threshold value in meters. The task calculates the distance from each crop center to the row line. It removes crops from that row if the distance is greater than the DISTANCE_THRESHOLD value that you provide. If you do not specify a value, the distance threshold is one-third of the row spacing, by default. If the input crops object does not have a spatial reference, enter the distance in pixels.

FILLED (optional)

Set this property to true to create filled circles in the output crops classification raster. The default is false.

INLIER_FRACTION (optional)

Specify a value ranging from 0 to 1.0. This is the fraction of candidate crops that each row should consist of, to be considered a valid row. The default value is 0.5 (50%). If the crops object has too many outliers, the tool will not correctly filter them out. In this case, set INLIER_FRACTION to a higher fraction to remove more outliers. If the rows vary greatly in the number of crops they contain, then set this parameter to a smaller fraction. Increase this value if there are many outliers and they are being identified as false rows. If the rows vary greatly from the rows surrounding them (not gradually across the field), then set this parameter to a smaller fraction. This parameter can be used in conjunction with MINIMUM_CROPS_PER_ROW, which sets an absolute minimum for all rows. For instance, say a field gradually varies from 50 crops per row on the left to 20 crops per row on the right. With the default fraction of 0.5, rows on the left must have at least 25 crops and rows on the right must have at least 10. If there are many outliers and there are false rows with more than 25 crops on the left and 10 on the right, the inlier fraction can be increased to exclude them. On the other hand, if there was a single valid row of 20 crops on the left (next to the rows of 50), an inlier fraction of 0.5 would exclude it and the fraction would have to be lowered.

INPUT_CROPS (required)

Specify an input ENVIAgCrops object.

MAXIMUM_SLOPE (optional)

Specify the maximum amount (in degrees) that the slope of a row line can differ from the primary direction that the algoritihm initially determined. For example, if the field direction is 45 degrees and you specify a value of 1, then the row lines can have a slope of 44 to 46 degrees to be valid. The default value is 2 degrees.

MINIMUM_CROPS_PER_ROW (optional)

Specify the number of crops required to be considered a row. The minimum number is 2, and the default is 3.

NAME

This property contains the name of the task.

OUTPUT_CROPS

This is a reference to the output crop data, after outliers have been removed.

OUTPUT_CROPS_URI (optional)

Specify a string with the fully qualified path and filename for OUTPUT_CROPS. If you do not specify this property, the output crop file is only temporary. Once the crop file has no remaining references, ENVI deletes the temporary file.

OUTPUT_NCROPS

This is the output number of crops, after outliers have been removed.

OUTPUT_NREMOVED

This is the number of crops removed because they did not belong in a row.

OUTPUT_NROWS

This is the number of crop rows found.

OUTPUT_RASTER

This is a reference to the output crops classification raster.

OUTPUT_RASTER_URI (optional)

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.

OUTPUT_REMOVED_CROPS

This is a reference to the output ENVIAgCrops object containing the removed crops.

OUTPUT_REMOVED_CROPS_URI (optional)

Specify a string with the fully qualified filename and path for the output JSON file that will contain the removed crops.

OUTPUT_ROW_ROIS

This is a reference to an output array of ROIs identifying the crop rows.

OUTPUT_ROW_ROIS_URI (optional)

Specify a string with the fully qualified filename and path for the output XML file containing the crop row ROIs.

Version History


1.0.1

Introduced

See Also


ENVIAgCropCountTask, ENVIAgFindAndRasterizeCropGapsTask



© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us