繁体   English   中英

R:使用不同的颜色绘制栅格中的特定值

[英]R: Plotting specific values in raster using different colour

如何仅使那些等于零的栅格像元变白?

library(raster)
r <- raster(ncol=5, nrow=5)
val<- c(0,0,0.01,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,
    0.85,0.9,0.95,1.0,1.2,1.3,1.63)
values(r) <- val
plot(r, col=c("gray","green","red","orange"), 
        breaks=c(0.1,0.4,0.8,1.2,1.63))
text(r, digits=2)

在此处输入图片说明

您的颜色多于断点,但否则,它似乎可以正常工作:

library(raster)
r <- raster(ncol=5, nrow=5)
values(r) <- sort(runif(ncell(r), 0, 1.5))
plot(r, col=c("gray","green","red","orange","blue"), 
     breaks=c(0,0.1,0.4,0.8,1.2,1.63))
text(r, digits=2)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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