我试图找到一种方法来添加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()