Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

lines

Add SpatVector data to a map


Description

Add SpatVector data to a plot (map) with points, lines, or polys.

These are simpler alternatives for plot(x, add=TRUE)

Usage

## S4 method for signature 'SpatVector'
points(x, col, cex=1, pch=20, ...)

## S4 method for signature 'SpatVector'
lines(x, y=NULL, col, lwd=1, lty=1, arrows=FALSE, ...)

## S4 method for signature 'SpatVector'
polys(x, col, border="black", lwd=1, lty=1, ...)

## S4 method for signature 'SpatExtent'
points(x, col, ...)

## S4 method for signature 'SpatExtent'
lines(x, col, ...)

Arguments

x

SpatVector or SpatExtent

y

missing or SpatVector. If both x and y have point geometry and the same number of rows, lines are drawn between pairs of points

col

character. Colors

border

character. color(s) of the polygon borders. Use NULL or NA to not draw a border

cex

numeric. point size magnifier. See par

pch

positive integer, line type. See points

lwd

numeric, line-width. See par

lty

positive integer, line type. See par

arrows

logical. If TRUE and y is a SpatVector, arrows are drawn intead of lines. See ?arrows for additional arguments

...

additional graphical arguments such as lwd, cex and pch

Examples

f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)

r <- rast(v)
values(r) <- 1:ncell(r)
plot(r)
lines(v)
points(v)

terra

Spatial Data Analysis

v1.2-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>), Roger Bivand [ctb] (<https://orcid.org/0000-0003-2392-6140>), Karl Forner [ctb], Jeroen Ooms [ctb] (<https://orcid.org/0000-0002-4035-0289>), Edzer Pebesma [ctb] (<https://orcid.org/0000-0001-8049-7069>)
Initial release
2021-05-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.