我有一个要绘制的栅格。每个唯一值对应于在查找表(lut)中找到的特定符号体系(即值,名称,颜色(RGB和十六进制))。如何绘制基于lut约束输出的栅格?此外,图例中的每个值都应具有单独的图标。
##Here are the first 4x lines from my lut
value name r g b hex
1 abc 209 255 115 #D1FF73
22 def 196 189 151 #C4BD97
550 ghi 115 223 255 #73DFFF
980 jkl 204 204 204 #CCCCCC
##Code
x <- raster(xyz.asc)
unique.x <- data.frame(unique(x))
names(unique.x) <- c("value")
lut <- read.csv("lut.csv")
lut <- lut[order(lut$value), ]
##subset lut based on unique values found within x
lut <- lut[lut$value %in% unique.x$value, ]
##here is where I am lost (or perhaps earlier too)
plot(x, breaks=lut$value, box=F, axes=F)
##the code above works, but:
#i. when I add in "col=lut$hex" I get the error "Error in rgb(tx, tx, tx,
#maxColorValue = max) : color intensity 16, not in [0,1]"; and,
#ii. the legend is a gradient with overlying labels - not ideal