# NOT RUN {
r <- rast(system.file("ex/elev.tif", package="terra"))
plot(r)
contour(r, add=TRUE)
v <- as.contour(r)
plot(r)
lines(v)
contour(r, filled=TRUE, nlevels=5)
## if you want a SpatVector with contour lines
#template <- disaggregate(rast(r), 10)
#rr <- resample(r, template)
#rr <- floor(rr/100) * 100
#v <- as.polygons(rr)
#plot(v, 1, col=terrain.colors(7))
# }
Run the code above in your browser using DataLab