如何在ggmap上叠加透明栅格?

时间:2018-02-23 20:06:55

标签: r ggplot2 raster ggmap r-raster

我试图找到一种方法来添加alpha功能,以便在raster layer上覆盖ggmap。有一些建议such as converting raster to shapefile,但我想使用raster file。有没有办法添加alpha并制作raster图层transparent

library(raster)
library(ggmap)
location <- get_map(location = c(lon =22, lat =40), zoom = 6, maptype = "hybrid")
# get the raster layer
tmin <- raster::getData('worldclim', var='tmin', res=0.5, lon=22, lat=40)[[1]]
ggmap(location)+inset_raster(as.raster(tmin), xmin = tmin@extent[1], xmax = tmin@extent[2],ymin =tmin@extent[3], ymax = tmin@extent[4])+ coord_cartesian()

enter image description here

0 个答案:

没有答案