Draw multiple polygon on a nativeRaster image

nr_polygon(
  nr,
  x,
  y,
  id = NULL,
  fill = "black",
  color = NA,
  linewidth = 1,
  mitre_limit = linewidth
)

Arguments

nr

nativeRaster

x, y

Vectors of point coordinates

id

integer vector used to separate coordinates into multiple polygons. Consecutive runs of the same id value belong to the same polygon. If NULL (the default) then all coordinates are assumed to be vertices of a single polygon.

fill

fill color

color

Color as a character string. Either a standard R color (e.g. 'blue', 'white') or a hex color of the form #rrggbbaa, #rrggbb, #rgba or #rgb

linewidth

Line linewidth. Default: 1. If linewidth = 1 then a naive version of Bresenham is used to draw the points. If linewidth is greater than 1, then the line is convert to a triangle strip and rendered as polygons.

mitre_limit

Limit the size of the mitre when two lines meet at an acute angle and linewidth is greater than 1. Default: same as line linewidth which mostly looks OK.

Value

Original nativeRaster modified in-place

Examples

N <- 200
nr <- nr_new(N, N, 'grey80')
nr_polygon(nr, x = c(10, N-10, 10), y = c(10, 10, N-10), fill = 'blue', 
           color = 'red', linewidth = 5)
plot(nr, TRUE)