Learn R Programming

terra (version 1.1-4)

NAflag: Set a value to NA

Description

Set a particular value of a SpatRaster to NA. If the values are in memory the change is made immediately. If the values are on disk, the changes is only made for values read from the file ("lazy evaluation").

Usage

# S4 method for SpatRaster
NAflag(x)

# S4 method for SpatRaster NAflag(x)<-value

Arguments

x

SpatRaster

value

numeric. The value to be interpreted as NA; set this before reading the values from the file. This can be a single value, or multiple values, one for each data source (file / subdataset)

Value

none or numeric

Examples

Run this code
# NOT RUN {
s <- rast(system.file("ex/logo.tif", package="terra"))[[1]]   
NAflag(s) <- 255
plot(s)
NAflag(s)
# }

Run the code above in your browser using DataLab