сюжетная горка в tmap - PullRequest
       35

сюжетная горка в tmap

0 голосов
/ 03 сентября 2018

Я хотел бы построить растр с Hilshading и добавить слои с 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)

enter image description here

Я бы хотел наложить дороги и т. Д., Используя 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.

1 Ответ

0 голосов
/ 06 сентября 2018
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)

Благодаря Nowosad на странице tmap github .

...