I am new in R.
How can I replace NAs with 0 for my raster data which have spatial information?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI am new in R.
How can I replace NAs with 0 for my raster data which have spatial information?
The answer from Wilfried Thuiller in R-SIG-Geo mailing list works:
#getting a raster
library(raster)
f <- system.file("external/test.grd", package="raster")
f
r <- raster(f) #r is the object of class 'raster'.
# replacing NA's by zero
r[is.na(r[])] <- 0