简体   繁体   中英

Specifying color of NA raster values in levelplot (R package rasterVis)

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

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)

具有背景色的水平图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM