首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在tmap中绘制山坡

在tmap中绘制山坡
EN

Stack Overflow用户
提问于 2018-09-03 13:41:41
回答 1查看 616关注 0票数 2

我想用山坡遮阳来绘制光栅,用tmap添加图层。

代码语言:javascript
复制
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。怎样才能做到这一点?

代码语言:javascript
复制
library(tmap)
tm_shape(hill) + tm_raster() + tm_shape(alt) + tm_raster()

是相同的

代码语言:javascript
复制
tm_shape(alt) + tm_raster()

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

代码语言:javascript
复制
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.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-06 07:00:33

代码语言:javascript
复制
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页面上的诺瓦萨。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52150972

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档