R小叶addWMStiles与投影

时间:2017-02-02 14:04:36

标签: r leaflet wms

我试图遵循这个例子:https://rpubs.com/cyclemumner/228100,特别是添加了带有custum投影的wms tile的部分,但是当我运行代码时,我似乎没有得到wms tile 。 我已经从github安装了传单。

if (!require('devtools')) install.packages('devtools')
devtools::install_github('rstudio/leaflet')

使用传单1.0.2.9010,R R-3.3.2和RStudio 1.0.136。

我运行的代码如下

library(leaflet)

zoom <- 1
maxZoom <- 5

crsAntartica <-  leafletCRS(
  crsClass = 'L.Proj.CRS',
  code = 'EPSG:3031',
  proj4def = '+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs',
  resolutions = c(8192, 4096, 2048, 1024, 512, 256),
  origin = c(-4194304, 4194304),
  bounds =  list( c(-4194304, -4194304), c(4194304, 4194304) )
)

leaflet(options= leafletOptions(crs=crsAntartica, minZoom = zoom, maxZoom=maxZoom, worldCopyJump = FALSE)) %>%
  setView(0, -90, 0) %>%
  addWMSTiles(baseUrl="https://maps.environments.aq/mapcache/antarc/?",
              layers="antarc_ramp_bath_shade_mask",
              options=WMSTileOptions(format="image/png",transparent=TRUE),
              attribution="xxx") %>%
  addGraticule()

我得到的是这个

enter image description here

关于我做错的任何想法?

2 个答案:

答案 0 :(得分:1)

找到我没有让它工作的原因。在RStudio查看器中查看时,wms图块不会显示。当我把代码放在一个闪亮的应用程序中时,我正在处理wms图块。

答案 1 :(得分:0)

如果您使用的是 RStudio :我只是遇到了同样的问题,因此找到了一个简单的解决方案,可以查看所有内容。只需使用“在新窗口中显示”即可:

enter image description here

使用一些随机数据,结果如下:

enter image description here