【问题标题】:R - Leaflet WMTS layer is not renderingR - Leaflet WMTS 层未呈现
【发布时间】:2018-07-11 19:45:38
【问题描述】:

我正在使用以下网址将 WMTS 图层添加到我的 R Leaflet 地图中:

https://mrdata.usgs.gov/mapcache/wmts?layer=alteration&service=WMTS&request=GetCapabilities&version=1.0.0

我在 R Leaflet 中的“addWMSTiles”选项下将 url 添加到我的代码中,如下所示:

library(shiny)
library(leaflet)

ui <- shinyUI(
fluidPage(
    leafletOutput("map", width = "100%", height = "900px")
)
)

server <- function(input, output) {

output$map <- renderLeaflet({
    leaflet() %>%
        addTiles() %>%
        setView(-93.65, 42.0285, zoom = 4) %>%
        addWMSTiles("https://mrdata.usgs.gov/mapcache/wmts?layer=alteration&service=WMTS&request=GetCapabilities&version=1.0.0",
            layers = "sim3340",
            options = WMSTileOptions(format = "image/png", transparent = TRUE),
            attribution = "")
})
}

app <- shinyApp(ui = ui, server = server)
runApp(app, launch.browser = TRUE)

当我运行此代码时,地图将显示在浏览器中,但显示的只是基本传单 (OpenStreets) 地图(下图)。

当 CA 和 AZ 周围应该有一些颜色时,因为那是 WMTS 图层正在突出显示。

起初我认为这可能是由于 WMTS 层中有 3 个不同的投影矩阵,但即使我在 addWMSTiles 选项中调用 crs = "EPSG:6.3:3857" 它仍然显示为底图。

我需要更改或添加什么才能使此 WMTS 图层显示在地图上?

谢谢您,我们一如既往地感谢您的帮助!

【问题讨论】:

    标签: r leaflet maps


    【解决方案1】:

    应该这样做。对您的baseUrl 的调用不正确。

    library(shiny)
    library(leaflet)
    
    ui <- shinyUI(
      fluidPage(
        leafletOutput("map", width = "100%", height = "900px")
      )
    )
    
    server <- function(input, output) {
    
      output$map <- renderLeaflet({
        leaflet() %>%
          addTiles() %>%
          setView(-93.65, 42.0285, zoom = 4) %>%
          addWMSTiles(baseUrl = "https://mrdata.usgs.gov/mapcache/wms/",
                      layers = "sim3340",
                      options = WMSTileOptions(format = "image/png", transparent = TRUE),
                      attribution = "")
      })
    }
    
    app <- shinyApp(ui = ui, server = server)
    runApp(app, launch.browser = TRUE)
    

    【讨论】:

    • 谢谢!我看到您正在使用 WMS 层...R 中的传单不能与 WMTS 层一起使用吗?
    • 我认为它使用 wms 作为 WMTS。如果放大,您将看到不同的磁贴。查看this page 了解更多示例。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-27
    • 2017-06-04
    • 2014-02-19
    相关资源
    最近更新 更多