How can I assign a specific color to NA values of a raster when plotting it with the levelplot function from R-package rasterVis? I am searching for a similar functionality as "colNA".
Asked
Active
Viewed 2,486 times
2
-
1Examples generally prompt more interest than request to construct entire examples. Often you can just start with code cut from the help pages. – IRTFM Apr 01 '15 at 20:29
1 Answers
9
levelplot
uses the background color to display the NA
values. Thus, you have to modify this color using panel.background
.
library(rasterVis)
myTheme <- BTCTheme()
myTheme$panel.background$col = 'gray'
f <- system.file("external/test.grd", package="raster")
r <- raster(f)
levelplot(r, par.settings = myTheme)

Oscar Perpiñán
- 4,491
- 17
- 28