Basic Visualization with sf

library(sf)
# open watershed data
ws <- st_read("data/source/watersheds/WBDHU12.shp")

# Basic Plotting ----------------------------------------------------------

plot(st_geometry(ws), col = "blue")

plot(st_geometry(ws), col = "blue", border = "grey")

plot(st_geometry(ws), col = "blue", border = "grey", axes = TRUE)

plot(st_geometry(ws), col = "blue", border = "grey", axes = TRUE, lwd = 2)

plot(st_geometry(ws), col = "blue", border = "grey", 
     axes = TRUE, lwd = 2, main = "Watershed Boundaries")

plot(st_geometry(ws[1,]), col = "red", add = TRUE)
plot(st_geometry(ws[20,]), col = "red", add = TRUE)

plot(st_geometry(ws), col = "blue", border = "grey", 
     axes = TRUE, lwd = 2, main = "Watersheds of Interest")

unique(ws$name) # view names to get a name for filtering
plot(st_geometry(ws[ws$name == "Upper Dry Creek",]), col = "red", add = TRUE)
plot(st_geometry(ws[ws$name == "Horse Creek",]), col = "red", add = TRUE)

# Continuous Data ---------------------------------------------------------

plot(ws["areaacres"], nbreaks = 3, breaks = "jenks", axes = TRUE, lwd = 2,
     main = "Watershed Acreage")
# Save a pdf output
pdf("outputs/watershed_test_map.pdf")
plot(ws["areaacres"], nbreaks = 3, breaks = "jenks", axes = TRUE, lwd = 2,
     main = "Watershed Acreage", pal = colorRampPalette(c("blue", "red")))
dev.off()