R:传单:将窗格与addRasterImage一起使用

时间:2019-02-13 20:40:33

标签: r leaflet

R的传单现在可以选择使用addMapPane以确定的顺序堆叠传单对象。这对于矢量数据而言效果很好,但与addRasterImage一起使用会返回错误消息。是否有特殊的options可以将pane与栅格一起使用?

library(leaflet)
library(raster)

r <- raster(ncol=1000, nrow=1000)
r[] <- runif(ncell(r),0,1)
extent(r) <- matrix(c(172, -37, 175, -38), nrow=2)
crs(r)<-sp::CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
pal <- colorNumeric(c("#0C2C84", "#41B6C4", "#FFFFCC"), values(r),
                    na.color = "transparent")


m <- leaflet(m) %>% addTiles() %>% 
  addMapPane("baseMap", zIndex = 410) %>% 
  addMapPane("baseSat", zIndex = 420) %>% 
  addMapPane("data", zIndex = 425) %>% 
  addMapPane("r", zIndex = 430) %>% 
  addProviderTiles(providers$Esri.WorldImagery, group = "Satellite imagery",
                   options = pathOptions(pane = "baseSat")) %>% 
  addProviderTiles(providers$Esri.WorldTerrain,
                   options = pathOptions(pane = "baseMap")) %>% 
  addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R", 
             options = pathOptions(pane = "data")) %>% 
  addRasterImage(r, colors = pal, opacity = 0.8, project = FALSE, 
                 options = pathOptions(pane = "r"))

Error in addRasterImage(., r, colors = pal, opacity = 0.8, project = FALSE,  : 
  unused argument (options = pathOptions(pane = "r"))

0 个答案:

没有答案