2

I'm trying to add WMS tiles in the R leaflet package - not a problem using this example 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 = "")

However, when I try using WMS from the National Map, I continue to get empty leaflet results despite multiple attempts at trying to set parameters correctly for url and layers:

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 = "") 

I've not used leaflet before outside the R leaflet package, so this may be a very novice mistake in setting my parameters in leaflet using this type of WMS

1
  • You may find this link helpful. It seems that you need to go through a registration process for arcgis; "in order to use ArcGIS maps, you must register and abide by the terms of service. No special syntax is required."
    – jazzurro
    Oct 6, 2015 at 4:14

1 Answer 1

5

You just need to be zoomed in a little further for the layer to show up. Try this:

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 = "") 
1
  • do you know how to remove the WMS tile?
    – kraggle
    Jul 26 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.