-
Notifications
You must be signed in to change notification settings - Fork 4
/
1_fetch.R
53 lines (45 loc) · 1.26 KB
/
1_fetch.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
# Get spatial data into sf objects
source("1_fetch/src/maps_to_sf.R")
source("1_fetch/src/nhd_to_sf.R")
p1_targets <- list(
tar_target(
p1_conus_sf,
generate_conus_sf(p0_proj_str)
),
tar_target(
p1_conus_states_sf,
generate_conus_states_sf(p0_proj_str)
),
# Get basins
tar_target(
p1_huc8s_sf,
# do_union = TRUE will merge them based on each list
# element in `p0_huc8_list`
download_huc8_sf(huc8s = p0_huc8_list[[1]],
proj_str = p0_proj_str,
do_union = TRUE),
pattern = map(p0_huc8_list),
# Leave the sf objects as separate list items so that they
# can easily be branched over and converted to SVG.
iteration = "list"
),
# Save basins as sf for sharing out
tar_target(
p1_huc8s_sf_Rdata,
{
basins_sf <- p1_huc8s_sf %>% setNames(names(p0_huc8_list))
save(basins_sf ,
file = "1_fetch/out/IWS_basins_sf.Rdata")
}
),
# Get rivers by basin. Limit stream order
# to big streams only for now.
tar_target(
p1_rivers_sf,
download_rivers_sf(aoi_sf = p1_huc8s_sf,
proj_str = p0_proj_str,
streamorder = 6),
pattern = map(p1_huc8s_sf),
iteration = "list"
)
)