【问题标题】:plot hillshade in tmap在 tmap 中绘制山体阴影
【发布时间】:2019-02-08 13:59:25
【问题描述】:

我想用hillshading 绘制一个栅格并用tmap 添加图层。

library(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)

我想使用tmap 覆盖道路等。如何使这项工作?

library(tmap)
tm_shape(hill) + tm_raster() + tm_shape(alt) + tm_raster()

一样
tm_shape(alt) + tm_raster()

tm_shape(hill) + tm_raster() 部分给出警告信息:

Variable "layer" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.

【问题讨论】:

    标签: r raster tmap


    【解决方案1】:
    library(tmap)  
    tm_shape(hill) +
     tm_raster(palette = gray(0:100 / 100), n = 100, legend.show = FALSE)  +
      tm_shape(alt) +
      tm_raster(alpha = 0.5, palette = terrain.colors(25),
                legend.show = FALSE)
    

    感谢 tmap github page 上的 Nowosad。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-22
      • 2010-11-16
      • 2014-02-24
      • 2012-02-16
      • 1970-01-01
      • 2017-03-31
      • 2016-11-14
      • 2012-03-03
      相关资源
      最近更新 更多