-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwrangle-watersheds.R
51 lines (38 loc) · 1.89 KB
/
wrangle-watersheds.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
## ------------------------------------------------------- ##
# Silica WG - Wrangle Watershed Shapefiles
## ------------------------------------------------------- ##
# Written by:
## Nick J Lyon
# Edited by Sidney Bush -- for data release 2
## LATER: will need to add HydroSHEDS sites for: Murray-Darling (Australia) and Canada sites
# Purpose:
## Wrangle "artisanal" watershed shapefiles into a single file to extract driver data
## Artisanal = mixed provenance / provided by WG participants
## ------------------------------------------------------- ##
# Housekeeping -----
## ------------------------------------------------------- ##
# Read needed libraries
# install.packages("librarian")
librarian::shelf(tidyverse, magrittr, googledrive, sf, supportR, NCEAS/scicomptools, readxl)
# Clear environment
rm(list = ls())
# Identify path to location of shared data
(path <- scicomptools::wd_loc(local = F, remote_path = file.path('/', "home", "shares", "lter-si", "si-watershed-extract")))
# source("wrangle-artisanal-watersheds.R")
# source("wrangle-hydrosheds.R")
## ------------------------------------------------------- ##
# Acquire Shapefiles ----
## ------------------------------------------------------- ##
artisan <- sf::st_read(file.path(path, "site-coordinates", "silica-watersheds_artisanal.shp"))
hydro <- sf::st_read(file.path(path, "site-coordinates", "silica-watersheds_hydrosheds.shp"))
all_shps <- dplyr::bind_rows(artisan, hydro)
dplyr::glimpse(all_shps)
## ------------------------------------------------------- ##
# Export Results ----
## ------------------------------------------------------- ##
# Export the combine shapefile for all rivers
sf::st_write(obj = all_shps, delete_layer = T,
dsn = file.path(path, "site-coordinates", "silica-watersheds.shp"))
# Tidy up environment
rm(list = ls()); gc()
# End ----