adjustPolygon: Interactively move vertices of a polygon

adjustPolygonR Documentation

Interactively move vertices of a polygon

Description

adjustPolygon interactively moves vertices of a polygon and saves the result.

Usage

adjustPolygon(xy, colLine = "red", colPoly = "purple", alpha = 0.25, borderPoly = 'black', add = FALSE, closePoly = TRUE, lty = "solid", colBg = par()$bg, ...)

Arguments

xy

A matrix or data frame where the x-axis values (perhaps longitude) are in the first column and the y-axis column (perhaps latitude) are in the second column.

colLine

The color of line that is drawn while the points are adjusted. The default is red.

colPoly

The color for filling the polygon after the moving of the verticies has been finished.

alpha

An alpha transparency value for colPoly where 0 is fully transparent and 1 is opaque. The default is 0.25.

colBorder

The color of the polygon border after the moving of the verticies has been finished. The default is black. (The same default as polygon.)

add

When add is FALSE (the default) plot is called first. When add = TRUE the polygon is added to the current figure.

closePoly

When closePoly is TRUE (the default) the first point in the polygon is added to the end of polygon, ensuring the polygon is closed.

lty

The line type for the drawn lines and polygon. The default is: "solid" (equal to lty = 1).

colBg

The color to be used for the background of the device region. The default is the current background in par(): par()$bg

...

Addtional arguments passed to the lines and polygon functions.

Value

A matrix or data frame (equal to the form of the xy argument), with the final values as adjusted by the interactive manipulations of the vertices is invisibly returned.

Author(s)

John R. Wallace: John.Wallace@noaa.gov

See Also

draw.polygon, select.pts

Examples

## Not run: 

EEZ_test <- adjustPolygon(EEZ.Polygon.WestCoast) 
# Left click on a point and then left click where to move the point. Repeat with the same point or any other point. 
# Right click to stop and the polygon will fill with 'colPoly' color (with transparency 'alpha') inside a border colored with 'borderPoly'.
  
# Readjust the result by using 'adjustPolygon' again
EEZ_test <- adjustPolygon(EEZ_test, colLine = 'green', colPoly = 'blue', borderPoly = 'green')  

  
imap() # Zoom into the west coast of the contiguous United States, allowing room for the EEZ polygon.
adjustPolygon(EEZ.Polygon.WestCoast, add = TRUE)  # Adjust the polygon as directed above.


## End(Not run)

John-R-Wallace/Imap documentation built on April 1, 2024, 6:27 a.m.