-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunner.R
111 lines (106 loc) · 7.14 KB
/
runner.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
library(dataRetrieval)
library(sf)
library(rmapshaper)
library(readr)
library(dplyr)
library(drake)
library(rvest)
sf::sf_use_s2(FALSE)
if(!"mapshaper-xl" %in% names(check_sys_mapshaper())) stop("rmapshaper xml must be available")
sourced <- sapply(list.files("R", pattern = "*.R", full.names = TRUE), source)
plan <- drake_plan(nwis_sites = get_nwis_sites(),
nwis_well_sites = get_nwis_well_sites(nwis_sites),
nwis_wells = get_nwis_wells(nwis_well_sites),
nwis_wells_out = sf::write_sf(nwis_wells, "out/nwis_wells.geojson"),
POIs = get_gf_11_poi(),
v1_v2 = get_nhdplus_crosswalk(),
nhdplusv2_flines = get_v2_flowlines(),
nhdplus2_attributes = sf::st_drop_geometry(nhdplusv2_flines),
gf11_pois = index_pois(POIs, v1_v2, flines = nhdplusv2_flines),
gnis_f = download_gnis(),
huc = target(
make_nwis_huc_redirects(nwis_sites,
file_out("out/hydrologic-unit.csv"))),
wbd_gdb = get_wbd_gdb("data/wbd/"),
hu02 = get_hu(wbd_gdb = wbd_gdb,
hu_layer = "WBDHU2",
id_attribute = "huc2",
pid_base = "https://geoconnex.us/ref/hu02/",
out = file_out("out/hu02.gpkg"),
landing_base = "https://reference.geoconnex.us/collections/hu02/items/",
csv_out = file_out("out/hu02.csv"),
description = "two digit hydrologic units reference",
creator = "[email protected]"),
hu04 = get_hu(wbd_gdb = wbd_gdb,
hu_layer = "WBDHU4",
id_attribute = "huc4",
pid_base = "https://geoconnex.us/ref/hu04/",
out = file_out("out/hu04.gpkg"),
landing_base = "https://reference.geoconnex.us/collections/hu04/items/",
csv_out = file_out("out/hu04.csv"),
description = "four digit hydrologic units reference",
creator = "[email protected]"),
hu06 = get_hu(wbd_gdb = wbd_gdb,
hu_layer = "WBDHU6",
id_attribute = "huc6",
pid_base = "https://geoconnex.us/ref/hu06/",
out = file_out("out/hu06.gpkg"),
landing_base = "https://reference.geoconnex.us/collections/hu06/items/",
csv_out = file_out("out/hu06.csv"),
description = "six digit hydrologic units reference",
creator = "[email protected]"),
hu08 = get_hu(wbd_gdb = wbd_gdb,
hu_layer = "WBDHU8",
id_attribute = "huc8",
pid_base = "https://geoconnex.us/ref/hu08/",
out = file_out("out/hu08.gpkg"),
landing_base = "https://reference.geoconnex.us/collections/hu08/items/",
csv_out = file_out("out/hu08.csv"),
description = "eight digit hydrologic units reference",
creator = "[email protected]"),
hu10 = get_hu(wbd_gdb = wbd_gdb,
hu_layer = "WBDHU10",
id_attribute = "huc10",
pid_base = "https://geoconnex.us/ref/hu10/",
out = file_out("out/hu10.gpkg"),
landing_base = "https://reference.geoconnex.us/collections/hu10/items/",
csv_out = file_out("out/hu10.csv"),
description = "ten digit hydrologic units reference",
creator = "[email protected]"),
ngwmn_wfs_call = "https://cida.usgs.gov/ngwmn/geoserver/wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=ngwmn:aquifrp025&outputFormat=application%2Fjson",
nwis_aq_names = as.data.frame(
rvest::html_table(rvest::read_html(
"https://help.waterdata.usgs.gov/aqfr_cd"))[[1]]),
nwis_aq = make_nwis_aq(nwis_well_sites, nwis_aq_names,
area_filter = units::set_units(1e12, "m^2"),
min_wells = 100),
nat_aq = sf::read_sf(ngwmn_wfs_call),
nat_aq_links = get_national_aquifer_html(),
nat_aq_out = write_nat_aq(nat_aq,
pid_base = "https://geoconnex.us/ref/nat_aq/",
landing_base = "https://reference.geoconnex.us/collections/nat_aq/items/",
pa_base = "https://geoconnex.us/ref/principal_aq/",
links = nat_aq_links,
out = file_out("out/nat_aq.gpkg"),
out_csv = file_out("out/nat_aq.csv")),
pa_shp = get_principal_aquifers(),
principal_aquifer = sf::read_sf(pa_shp),
pa_out = write_pa(principal_aquifer,
pid_base = "https://geoconnex.us/ref/principal_aq/",
landing_base = "https://reference.geoconnex.us/collections/principal_aq/items/",
nat_aq_out,
out = file_out("out/princi_aq.gpkg"),
out_csv = file_out("out/princi_aq.csv")),
shr_ids = readr::read_csv("data/SHR_ID.csv"),
shr_gdb = get_secondary_gydrogeologic_regions(),
secondary_hydrogeologic_regions = sf::read_sf(shr_gdb, "Secondary_Hydrogeologic_Regions"),
shr_out = write_shr(secondary_hydrogeologic_regions,
pid_base = "https://geoconnex.us/ref/sec_hydrg_reg/",
landing_base = "https://reference.geoconnex.us/collections/sec_hydrg_reg/items/",
shr_ids = shr_ids,
out = file_out("out/sec_hydrg_reg.gpkg"),
out_csv = file_out("out/sec_hydrg_reg.csv")),
wade_sites = sf::read_sf("https://www.hydroshare.org/resource/5f665b7b82d74476930712f7e423a0d2/data/contents/wade_sites.geojson"),
wade_nldi = make_wade_nldi(wade_sites, file_out("out/wade.geojson")),
gnis = get_gnis(gnis_f, file_out("out/gnis.gpkg")))
make(plan)