library(sf)
## Warning: package 'sf' was built under R version 4.0.4
## Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(leaflet)
## Warning: package 'leaflet' was built under R version 4.0.4
library(leaflet.extras)
## Warning: package 'leaflet.extras' was built under R version 4.0.4
library(leaflet.esri)
## Warning: package 'leaflet.esri' was built under R version 4.0.4
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.0.4
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(RColorBrewer)
library(htmlwidgets)
## Warning: package 'htmlwidgets' was built under R version 4.0.4
library(htmltools)
## Warning: package 'htmltools' was built under R version 4.0.4
Trout <- st_read("C:/Users/jmhp2/Downloads/stockedTroutStreams_WVDNR_utm83_shp/stockedTroutStreams_WVDNR_utm83.shp")
## Reading layer `stockedTroutStreams_WVDNR_utm83' from data source `C:\Users\jmhp2\Downloads\stockedTroutStreams_WVDNR_utm83_shp\stockedTroutStreams_WVDNR_utm83.shp' using driver `ESRI Shapefile'
## replacing null geometries with empty geometries
## Simple feature collection with 2723 features and 23 fields (with 1 geometry empty)
## Geometry type: GEOMETRY
## Dimension: XY
## Bounding box: xmin: 373309.2 ymin: 4118261 xmax: 772818.9 ymax: 4489549
## Projected CRS: NAD83 / UTM zone 17N
Counties <- st_read("C:/Users/jmhp2/Downloads/countyBoundary_censusAndUSGS_200503_utm83_shp/countyBoundary_censusAndUSGS_200503_utm83.shp")
## Reading layer `countyBoundary_censusAndUSGS_200503_utm83' from data source `C:\Users\jmhp2\Downloads\countyBoundary_censusAndUSGS_200503_utm83_shp\countyBoundary_censusAndUSGS_200503_utm83.shp' using driver `ESRI Shapefile'
## Simple feature collection with 55 features and 27 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: 355937 ymin: 4117435 xmax: 782843.9 ymax: 4498773
## Projected CRS: NAD83 / UTM zone 17N
Trout_wm <- st_transform(Trout, crs=4326)
Counties_wm <- st_transform(Counties, crs=4326)
leaflet(Counties) %>%
addTiles(group = "OSM") %>%
addProviderTiles("Stamen.Watercolor") %>%
addPolygons(data= Counties_wm, color = "Black", weight = 2.5, group="Counties", popup = ~paste0("<b>", htmlEscape(NAME), "</b>", "<br>", htmlEscape(format(POP2000, big.mark=",")))) %>%
addPolylines(data= Trout_wm, color = "Blue", weight = 3.0, group = "Trout", popup = ~paste0("<b>", htmlEscape(DNRNAME),"</b>", "<br>", htmlEscape(format(EXTENT1, big.mark = ",")))) %>%
addLayersControl(overlayGroups=c("Counties"), baseGroups = c("OSM", "WV")) %>%
setView(lat= 39.1, lng= -80.4, zoom = 7)