select.RdGeometrically subset SpatRaster or SpatVector (to be done) by drawing on a plot (map).
Note that for many installations this does to work well on the default RStudio plotting device. To work around that, you can first run dev.new(noRStudioGD = TRUE) which will create a separate window for plotting, then use plot() followed by sel() and click on the map. It may also help to set your RStudio "Tools/Global Options/Appearance/Zoom" to 100
# S4 method for class 'SpatRaster'
sel(x, ...)
# S4 method for class 'SpatVector'
sel(x, use="rec", show=TRUE, col="cyan", draw=TRUE, ...)SpatRaster or SpatVector
character indicating what to draw. One of "rec" (rectangle) or "pol" (polygon)
logical. If TRUE the selected geometries are shown on the map
color to be used for drawing if draw=TRUE
logical. If TRUE the area drawn to select geometries is shown on the map
additional graphics arguments for drawing the selected geometries
SpatRaster or SpatVector
if (FALSE) { # \dontrun{
# select a subset of a SpatRaster
r <- rast(nrows=10, ncols=10)
values(r) <- 1:ncell(r)
plot(r)
s <- sel(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 <- sel(v) # now click on the map twice
x
} # }