2

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".

www
  • 38,575
  • 12
  • 48
  • 84
Christopher Stephan
  • 1,081
  • 16
  • 33
  • 1
    Examples 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 Answers1

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)

levelplot with background color

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