I need to replace the NA‘s in the raster object (r) from the example below.
library(raster)
filename <- system.file("external/test.grd", package="raster")
r <- raster(filename)
I also tried to remove these these (and place the result in a data.frame), but to no avail.
dfr <- as.data.frame(r, na.rm=T)
summary(dfr)
# test
# Min. : 128.4
# 1st Qu.: 293.2
# Median : 371.4
# Mean : 423.2
# 3rd Qu.: 499.8
# Max. :1805.8
# NA's :6097
I’m not sure it makes sense to remove
NAvalues from arasterobject, but you can easily replace it.For example:
If you really want to, you can extract the raster values into a vector and then remove the
NAvalues. (Although, since you lose the spatial information, I can’t see how this can be helpful.)