Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

select

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", draw=TRUE, col="cyan", ...)

Arguments

x

SpatRaster or SpatVector

use

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

draw

logial. If TRUE the selection is drawn on the map

col

color to be used for drawing if draw=TRUE

...

additional graphics arguments for drawing

Value

SpatRaster or SpatVector

See Also

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

Examples

## Not run: 
# select a subset of a SpatRaster
r <- rast(nrow=10, ncol=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)

terra

Spatial Data Analysis

v1.2-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>), Roger Bivand [ctb] (<https://orcid.org/0000-0003-2392-6140>), Karl Forner [ctb], Jeroen Ooms [ctb] (<https://orcid.org/0000-0002-4035-0289>), Edzer Pebesma [ctb] (<https://orcid.org/0000-0001-8049-7069>)
Initial release
2021-05-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.