Adding WMS basemap in R with mapview

Recently I wanted to be able to add a custom basemap of NHDPlus features to mapview leaflet maps. It’s not straitforward out of the box in mapview, but I found the helpful tips to do it here and here. Below I add the WMS service from EPA Waters along with USGS StreamGage stations in Benton County, OR using the dataRetrieval package. library(dataRetrieval) library(mapview) library(sf) library(leaflet) Stations <- readNWISdata(stateCd="Oregon", countyCd="Benton") # DataRetrival returns objects as 'attributes' - things like the url used, site metadata, site info, etc - just use attributes(Durham_Stations) to examine siteInfo <- attr(Stations , "siteInfo") stations_sf = st_as_sf(siteInfo, coords = c("dec_lon_va", "dec_lat_va"), crs = 4269,agr = "constant") m <- mapview(stations_sf) m@map = m@map %>% addWMSTiles(group = 'NHDPlus', "https://watersgeo. [Read More]

R Spatial Tutorial

Just finished putting together and running a half-day R Spatial Workshop covering some cool new R spatial things using packages such as sf, DataRetrieval, mapview, and combining dplyr chained operations with sf among other things. And I finally, after a year, got Disqus to start working on my blog! All I did was update blogdown and rebuild - if only everything were so simple…

Testing the simple features R package

Load and look at basics of simple features package library(devtools) # install_github("edzer/sfr") library(sf) ## Linking to GEOS 3.5.0, GDAL 2.1.1, proj.4 4.9.3 nc <- st_read(system.file("shape/nc.shp", package="sf")) ## Reading layer `nc' from data source `C:\Users\mweber\R\library\sf\shape\nc.shp' using driver `ESRI Shapefile' ## converted into: MULTIPOLYGON ## Simple feature collection with 100 features and 14 fields ## geometry type: MULTIPOLYGON ## dimension: XY ## bbox: xmin: -84.32385 ymin: 33.88199 xmax: -75. [Read More]