将国家水文数据集底图添加到传单地图中

时间:2019-05-15 20:14:24

标签: r leaflet gis

我想将NHD(国家水文数据集)底图(平铺)添加到我的传单地图中。 Here是提供我尝试使用的Hydrography网址的链接。

leaflet()%>%
  setView(lng = -76.4, lat = 37, zoom = 09) %>% 
  addWMSTiles(baseUrl="https://basemap.nationalmap.gov/arcgis/rest/services/USGSHydroCached/MapServer",
              layers="Hydrography")

当前返回的底图完全空白。我希望它看起来像this,从其他来源添加WMS磁贴似乎可以正常工作。

1 个答案:

答案 0 :(得分:0)

选项#1遵循USGS的this教程。

grp <- c("USGS Topo", "USGS Imagery Only", "USGS Imagery Topo","USGS Shaded Relief", "Hydrography")

GetURL <- function(service, host = "basemap.nationalmap.gov") {
sprintf("https://%s/arcgis/services/%s/MapServer/WmsServer", host, 
service)}`

opt <- leaflet::WMSTileOptions(format = "image/png", transparent = TRUE)

map <- leaflet::leaflet()
map <- leaflet::addWMSTiles(map, GetURL("USGSHydroCached"),
   group = grp[5], options = opt, layers = "0")

map <- leaflet::hideGroup(map, grp[5])`

选项#2使用inlmisc包,CreateWebMap函数默认情况下会添加水文学基础层