ENVIAnnotationSet::AddPolygon

The AddPolygon method adds a polygon to an annotation set.

Example

; Start the application

e = ENVI()

 

; Open an input file

file = FILEPATH('qb_boulder_msi', $

  ROOT_DIR=e.ROOT_DIR, SUBDIRECTORY = ['data'])

raster = e.OpenRaster(file)

 

; Display the raster layer

View = e.GetView()

RasterLayer = View.CreateLayer(raster)

 

; Create an annotation set using Geographic Lat/Lon

; WGS-84 as the spatial reference

annotation = ENVIAnnotationSet(/GEOGRAPHIC)

 

; Label some open space

annotation.AddPolygon, $

  [-105.2019956, -105.20388793, -105.20446003, $

  -105.20410246, -105.20195159, -105.2019956], $

  [40.00909537, 40.00863844, 40.0078896, $

  40.00670921, 40.00733114, 40.00909537], $

  LINE_COLOR='lime green', $

  NAME='Open space polygon'

 

annotation.AddText, $

  -105.20053465, 40.00640980, $ ; X and Y coordinates

  'Open space', $

  GLYPH_COLOR='lime green', $

  NAME='Open space label'

 

; Save the annotation set

outFile = e.GetTemporaryFilename()

annotation.Save, outFile

 

; Display the annotation layer

AnnLayer = View.CreateLayer(annotation)

View.Zoom, /FULL_EXTENT

Syntax

ENVIAnnotationSet.AddPolygon, X, Y [, Keywords=value]

Arguments

The first and last set of coordinates should be the same, and the polygon should have at least three unique points.

X

Specify a floating-point array with the X coordinates of the polygon vertices.

Y

Specify a floating-point array with the Y coordinates that correspond to X. The number of elements must match that of X, and they must be in the same corresponding order.

Keywords

ERROR (optional)

Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.

FILL_COLOR (optional)

Specify a three-element byte array or string with the fill color of the polygon, when FILL_MODE is set to 1. See the COLOR property of ENVIROI for a list of available colors.

FILL_CROSSHATCH (optional)

When FILL_MODE is set to 2 (Line), set this property to 1 to enable a crosshatch pattern. The default is 0.

FILL_MODE (optional)

Specify a Boolean value, indicating whether or not to fill the polygon.

FILL_ORIENTATION (optional)

When FILL_MODE is set to 2 (Line), specify the angular direction of the line fill. Values can range from 0 to 180. The default is 45.

FILL_SPACING (optional)

When FILL_MODE is set to 2 (Line), specify the spacing between the lines of the fill. Values range from 1 (solid fill) to 50. The default is 5.

LINE_COLOR (optional)

Specify a three-element byte array or string with the line color of the polygon. The default color is based on the current ENVI preference setting.

LINE_STYLE (optional)

Specify an integer value from 0 to 6, indicating the line style of the polygon. The choices are as follows:

Value

Line Style

0

1

2

3

4

5

6

No line

The default is 0 (solid line).

LINE_THICK (optional)

Specify a floating-point value from 1 to 10, indicating the line thickness of the polygon. The default value is 2. ENVI will round the value to the nearest integer.

LINE_SHOW (optional)

Specify a Boolean value, indicating whether or not to draw a line around the polygon.

NAME (optional)

Set this keyword to a string with a custom name for the annotation item. This name will appear in the Layer Manager. The default value is "Polygon."

Version History

ENVI 5.6.1

Introduced

API Version

4.2

See Also

ENVIAnnotationSet