lattice | R Documentation |
Represent lines, points and polygons
## S3 method for class 'SpatVector'
llines(x, ...)
## S3 method for class 'SpatVector'
lpoints(x, ...)
## S3 method for class 'SpatVector'
lpolygon(x, rule = "evenodd", ...)
x |
a SpatVector object |
rule |
character string specifying how ‘NA’ values are interpreted
for polygons. The default rule (‘"evenodd"’) interprets
‘NA’-separated segments as subpaths, possibly representing
holes, of a single path, and are rendered using
|
... |
Any argument that can be passed to
|
Alexandre Courtiol and Oscar Perpiñán
library(lattice)
library(latticeExtra)
library(terra)
library(rasterVis)
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
r <- rast(v)
values(r) <- 1:ncell(r)
pts <- terra::as.points(v)
levelplot(r, margin = FALSE) +
layer(lpoints(pts, col = "white"))
lns <- terra::as.lines(v)
levelplot(r, margin = FALSE) +
layer(llines(lns, col = "white", lty = 3))
pols <- terra::as.polygons(v)
levelplot(r, margin = FALSE) +
layer(lpolygon(pols, border = "black", col = "white"))
## Example adapted from the help page of terra::vect
x <- rbind(c(-10,0), c(140,60), c(160,0), c(140,-55))
hole <- rbind(c(50,0), c(105,30), c(120,2), c(105,-30))
z <- rbind(cbind(object=1, part=1, x, hole=0),
cbind(object=1, part=1, hole, hole=1))
colnames(z)[3:4] <- c('x', 'y')
p <- vect(z, "polygons", atts=data.frame(id=1))
crs(p) <- "+proj=longlat"
r <- rast(p)
values(r) <- runif(ncell(r))
levelplot(r, margin = FALSE) +
layer(lpolygon(p, border = "black", col = "white"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.