使用addWMSTiles在R小册子中加载WMS图层

时间:2015-10-06 00:48:18

标签: r leaflet wms

我正在尝试在R小册子包中添加WMS磁贴 - 使用此示例geoserver WMS不是问题:

leaflet() %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 4) %>%  addWMSTiles(
"http://sedac.ciesin.columbia.edu/geoserver/wms",
layers = "energy:energy-pop-exposure-nuclear-plants-locations_plants",
options = WMSTileOptions(format = "image/png", transparent = TRUE),
tileOptions(tms = TRUE),
attribution = "")

但是,当我尝试使用National Map中的WMS时,尽管多次尝试正确设置url和图层的参数,我仍然会得到空的传单结果:

leaflet() %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 4) %>%addWMSTiles(
"http://basemap.nationalmap.gov/arcgis/services/USGSHydroNHD/MapServer/WmsServer?",
layers = "0",
options = WMSTileOptions(format = "image/png", transparent = TRUE),
attribution = "") 

我没有在R小册子包之外使用传单,所以在使用这种类型的WMS设置传单中的参数时,这可能是一个非常新手的错误

1 个答案:

答案 0 :(得分:3)

您只需要进一步缩放以显示图层。试试这个:

leaflet() %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 7) %>%addWMSTiles(
"http://basemap.nationalmap.gov/arcgis/services/USGSHydroNHD/MapServer/WMSServer?",
layers = "0",
options = WMSTileOptions(format = "image/png", transparent = TRUE),
attribution = "")