我正在使用以下URL将WMTS图层添加到我的R Leaflet地图中:
我在R Leaflet的“ addWMSTiles”选项下将网址添加到代码中,如下所示:
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”,它仍然会显示为底图。 / p>
我需要更改或添加什么才能使此WMTS图层显示在地图上?
感谢您,一如既往的帮助!
答案 0 :(得分:0)
这应该做到。对您的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)