
Last chance! 50% off unlimited learning
Sale ends in
NA
s with specified valuesReplace NA
values on layers/attributes with specified values
# S3 method for SpatRaster
replace_na(data, replace = list(), ...)# S3 method for SpatVector
replace_na(data, replace, ...)
A Spat*
object of the same class than data
. Geometries and
spatial attributes are preserved.
A SpatRaster
created with terra::rast()
or a SpatVector
created with terra::vect()
.
list of values, with one value for each layer/attribute that
has NA
values to be replaced.
Ignored
Use r[is.na(r)] <- <replacement>
library(terra)
f <- system.file("extdata/cyl_temp.tif", package = "tidyterra")
r <- rast(f)
r %>% plot()
r %>%
replace_na(list(tavg_04 = 6, tavg_06 = 20)) %>%
plot()
Run the code above in your browser using DataLab