Geometrically subset SpatRaster or SpatVector (to be done) by drawing on a plot (map).
# S4 method for SpatRaster
select(x, ...)# S4 method for SpatVector
select(x, use="rec", draw=TRUE, col="cyan", ...)
SpatRaster or SpatVector
character indicating what to draw. One of "rec" (rectangle) or "pol" (polygon)
logial. If TRUE
the selection is drawn on the map
color to be used for drawing if draw=TRUE
additional graphics arguments for drawing
SpatRaster or SpatVector
crop
and intersect
to make an intersection and click
and text
to see cell values or geometry attributes
# NOT RUN {
# select a subset of a SpatRaster
r <- rast(nrow=10, ncol=10)
values(r) <- 1:ncell(r)
plot(r)
s <- select(r) # now click on the map twice
# plot the selection on a new canvas:
x11()
plot(s)
# vector
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
plot(v)
x <- select(v) # now click on the map twice
x
# }
Run the code above in your browser using DataLab