Skip to content

Instantly share code, notes, and snippets.

@mhweber
Created January 26, 2021 03:21
Show Gist options
  • Save mhweber/8198d8b80c37f63acd1d45fb4776f719 to your computer and use it in GitHub Desktop.
Save mhweber/8198d8b80c37f63acd1d45fb4776f719 to your computer and use it in GitHub Desktop.
Display WMS of NHDPlus NHD HR with mapview
library(mapview)
library(tidyr)
library(sf)
library(leaflet)
points <- tribble(~name, ~lat, ~lon,
'Point A',44.564568,-123.262047, )
points_sf <- st_as_sf(points, coords = c("lon", "lat"), crs = 4269)
m <- mapview(points_sf, legend=FALSE)
m@map <- m@map %>% addWMSTiles(group = 'NHDPlus',
"https://watersgeo.epa.gov/arcgis/services/NHDPlus_NP21/NHDSnapshot_NP21/MapServer/WmsServer?",
layers = 4,
options = WMSTileOptions(format = "image/png", transparent = TRUE),
attribution = "") %>% addWMSTiles(group = 'NHDPlusHR',
"https://hydro.nationalmap.gov/arcgis/services/NHDPlus_HR/MapServer/WMSServer?",
layers = 9,
options = WMSTileOptions(format = "image/png", transparent = TRUE),
attribution = "") %>% mapview:::mapViewLayersControl(names = c("NHDPlus","NHDPlusHR")) %>%
setView(-123.26, 44.56, zoom = 14)
m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment