The AddRectangle method adds a rectangle 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 a golf course
annotation.AddRectangle, $
  -105.22524234, $ ; X1
  40.01081803, $ ; Y1
  -105.21726630, $ ; X2
  40.00765892, $ ; Y2
  LINE_COLOR='lime green', $
  NAME='Golf course rectangle'
 
annotation.AddText, $
  -105.22105847, 40.00925448, $ ; X and Y coordinates
  'Flatirons Golf Course', $
  GLYPH_COLOR='lime green', $
  NAME='Golf course 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.AddRectangle, X1, Y1, X2, Y2 [, Keywords=value]

Arguments


X1

Specify a floating-point value with the X coordinate of one corner of the rectangle.

Y1

Specify a floating-point value with the Y coordinate that corresponds to X1.

X2

Specify a floating-point value with the X coordinate of an opposite corner of the rectangle.

Y2

Specify a floating-point value with the Y coordinate that corresponds to X2.

 

Keywords


ERROR

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 rectangle, 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 rectangle.

  • 0: None (default)
  • 1: Solid
  • 2: Line

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 rectangle. 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 rectangle. 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 rectangle. 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 rectangle.

  • 1: Line (default)
  • 0: No line

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 "Rectangle."

Version History


ENVI 5.6.1

Introduced

API Version


4.2

See Also


ENVIAnnotationSet