Learn R Programming

terra (version 1.7-83)

draw: Draw a polygon, line, extent, or points

Description

Draw on a plot (map) to get a SpatVector or SpatExtent object for later use. After calling the function, start clicking on the map. When you are done, press ESC. You can also preset the maximum number of clicks.

This does to work well on the default RStudio plotting device. To work around that, you can first run dev.new(noRStudioGD = TRUE) which will create a separate window for plotting, then use plot() followed by click() and click on the map.

Usage

# S4 method for character
draw(x="extent", col="red", lwd=2, id=FALSE, n=1000, xpd=TRUE, ...)

Value

SpatVector or SpatExtent

Arguments

x

character. The type of object to draw. One of "extent", "polygon", "line", or "points"

col

the color to be used

lwd

the width of the lines to be drawn

id

logical. If TRUE, a numeric ID is shown on the map

n

the maximum number of clicks (does not apply when x=="extent" in which case n is always 2)

xpd

logical. If TRUE, you can draw outside the current plotting area

...

additional graphics arguments for drawing

See Also

click