library(sf)
library(tidyverse)
library(mapview)
nc <- st_read(system.file("shape/nc.shp", package = "sf"), quiet = T)
download.file("https://opendata.arcgis.com/datasets/e5ddff9b96204c6181be7c022e61d946_0.zip?outSR=%7B%22latestWkid%22%3A32119%2C%22wkid%22%3A32119%7D",
destfile = "data/Gamelands.zip")
unzip("data/Gamelands.zip", exdir = "data/")
nc_gamelands <- st_read("data/679190a9-3cfb-4be4-9a1e-255188fd3f6e202044-1-707iid.5jdc8.shp", quiet = T)
Create a map that includes NC county boundaries, Game Lands, and hazardous waste sites. Data for the hazardous waste sites is available at https://www.nconemap.gov/datasets/hazardous-waste-sites
This data set represents the location of sites within North Carolina that are regulated by the hazardous waste portions of the Resource Conservation and Recovery Act (RCRA).
Let’s get the data.
download.file("https://opendata.arcgis.com/datasets/84ff6d8f569f4bb0965bfa906aa06e6d_2.zip?outSR=%7B%22latestWkid%22%3A32119%2C%22wkid%22%3A32119%7D",
destfile = "data/waste.zip")
unzip("data/waste.zip", exdir = "data/")
waste <- st_read("data/Hazardous_Waste_Sites.shp", quiet = T)
Next, we’ll put everything on the same coordinate reference system.
st_crs(nc)
#> Coordinate Reference System:
#> EPSG: 4267
#> proj4string: "+proj=longlat +datum=NAD27 +no_defs"
st_crs(nc_gamelands)
#> Coordinate Reference System:
#> EPSG: 32119
#> proj4string: "+proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
st_crs(waste)
#> Coordinate Reference System:
#> EPSG: 32119
#> proj4string: "+proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
nc <- st_transform(nc, st_crs(nc_gamelands))
Create three layers using mapview()
.
nc_mapview <- mapview(nc, alpha.regions = .2, alpha = .9,
label = nc[, "NAME", drop = T], popup = NULL,
layer.name = "NC Counties")
nc_gamelands_mapview <- mapview(nc_gamelands, col.regions = "#ff6700",
label = round(nc_gamelands[, "SUM_ACRES", drop = T], 2),
layer.name = "NC Gamelands")
nc_waste_mapview <- mapview(waste, col.regions = "#65ff00",
alpha = .3,
popup = NULL,
alpha.regions = .3,
label = waste[, "SITE_NAME", drop = T],
layer.name = "NC Waste Sites")
mapviewOptions(legend.pos = "bottomright")
nc_mapview + nc_gamelands_mapview + nc_waste_mapview