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)
# color by the values of a variable
plot(v, col="light gray", border="white")
lines(v, "NAME_1", lwd=5)
points(centroids(v), "AREA", cex=2, legend="topright")
Run the code above in your browser using DataLab