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

cover

Replace values with values from another object


Description

Replace NA or other values in SpatRaster x with the values of SpatRaster y

For polygons: areas of x that overlap with y are replaced by y or, if identity=TRUE intersected with y.

Usage

## S4 method for signature 'SpatRaster,SpatRaster'
cover(x, y, values=NA, filename="", ...)

## S4 method for signature 'SpatVector,SpatVector'
cover(x, y, identity=FALSE)

Arguments

x

SpatRaster or SpatVector

y

Same as x

values

numeric. The cell values in x to be replaced by the values in y

filename

character. Output filename

...

additional arguments for writing files as in writeRaster

identity

logical. If TRUE overlapping areas are intersected rather than replaced

Value

SpatRaster

Examples

r1 <- r2 <- rast(ncols=36, nrows=18)
values(r1) <- 1:ncell(r1)
values(r2) <- runif(ncell(r2))
r2 <- classify(r2, cbind(-Inf, 0.5, NA))
r3 <- cover(r2, r1)


p <- vect(system.file("ex/lux.shp", package="terra"))
e <- as.polygons(ext(6, 6.4, 49.75, 50))
values(e) <- data.frame(y=10)
#cv <- cover(p, e)
#plot(cv, col=rainbow(12))
#ci <- cover(p, e, identity=TRUE)
#lines(e, lwd=3)

#plot(ci, col=rainbow(12))
#lines(e, lwd=3)

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.