sel {terra}R Documentation

Spatial selection

Description

Geometrically subset SpatRaster or SpatVector (to be done) by drawing on a plot (map).

Usage

## S4 method for signature 'SpatRaster'
sel(x, ...)

## S4 method for signature 'SpatVector'
sel(x, use="rec", show=TRUE, col="cyan", draw=TRUE, ...)

Arguments

x

SpatRaster or SpatVector

use

character indicating what to draw. One of "rec" (rectangle) or "pol" (polygon)

show

logical. If TRUE the selected geometries are shown on the map

col

color to be used for drawing if draw=TRUE

draw

logical. If TRUE the area drawn to select geometries is shown on the map

...

additional graphics arguments for drawing the selected geometries

Value

SpatRaster or SpatVector

See Also

crop and intersect to make an intersection and click and text to see cell values or geometry attributes.

Use draw to draw a SpatExtent of SpatVector that you want to keep.

Examples

## Not run: 
# 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

## End(Not run)

[Package terra version 1.7-78 Index]