R中地图图的更好的山体阴影

R中地图图的更好的山体阴影,r,gis,R,Gis,我正在为一些地形图绘制改进的山体阴影。image()中记录的基本山体阴影工作流是: require(raster) alt = getData('alt', country='CHE') slope = terrain(alt, opt='slope') aspect = terrain(alt, opt='aspect') hill = hillShade(slope, aspect, 40, 270) plot(hill, col=grey(0:100/100), legend=FALSE,

我正在为一些地形图绘制改进的山体阴影。
image()
中记录的基本山体阴影工作流是:

require(raster)
alt = getData('alt', country='CHE')
slope = terrain(alt, opt='slope')
aspect = terrain(alt, opt='aspect')
hill = hillShade(slope, aspect, 40, 270)
plot(hill, col=grey(0:100/100), legend=FALSE, main='Switzerland')
plot(alt, col=rainbow(25, alpha=0.35), add=TRUE)
此图显示应用
绘图(alt..)
之前的
绘图(hill..)

该方法在山体阴影层下创建实心灰色,其他数据层(例如高程阴影)在该层上半透明地绘制。该方法的问题是(a)平坦地形的中性色(RBG(202202),“CACACA”)严重影响整个模型,这(b)防止了多个阴影分层,如该方法所用


我可以想象一种将光栅转换为矩阵并将山体阴影作为数字倍增应用于其他层的亮度的解决方法,但这似乎不是很优雅(尽管我可能错了)。我想知道是否有人在这方面有任何想法或(最好)经验?提前感谢。

没有这方面的经验,但是为什么不给灰色底图一个取决于坡度的alpha值呢?以下是我的尝试:

# before
require(raster)
alt = getData('alt', country='CHE')
slope = terrain(alt, opt='slope')
aspect = terrain(alt, opt='aspect')
hill = hillShade(slope, aspect, 40, 270)
plot(hill, col=grey(0:100/100), legend=FALSE, main='Switzerland')
plot(alt, col=rainbow(25, alpha=0.35), add=TRUE)

正如你所说,非常黑暗

# after
grayalphas <- seq(-1,1,by=.01)^2*100
grayalphas[grayalphas==100] <- 99
plot(hill, col=paste0(grey(0:100/100),sprintf("%.2d",grayalphas)), legend=FALSE, main='Switzerland')

plot(alt, col=rainbow(25, alpha=0.35), add=TRUE)

作为
addTrans
的打包替代品,
scales
包中有
alpha
。@shujaa谢谢你的提示,我不知道!这是我不时需要的东西,我发现它非常有用。它以前在
ggplot2
中,但当我更新时,我感到恐慌,它不见了!很高兴意识到这些功能正变得更加合适。但是现在我记得@BenBolker曾经给我指出过
?adjustcolor
,它默认加载,可以做同样的工作(甚至更多)。那么@geotheory提出这个问题后,你在这方面有什么进展吗?如果你有一些巧妙的工作,也可以随意发布一个答案。蒂姆,还没有,我为你偏离了方向而道歉。我已经接受了你的回答。我会在这里发布你们可能觉得有用的任何东西。
grayalphas <- seq(-1,1,length=101)^2*255
plot(hill, col=addTrans(grey(0:100/100),grayalphas), legend=FALSE, main='Switzerland')
plot(alt, col=rainbow(25, alpha=0.35), add=TRUE)