Skip to content

Commit

Permalink
conus-ref-fab: update POIs from GS
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejohnson51 committed May 28, 2024
1 parent 12216d0 commit b2e9d24
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
7 changes: 5 additions & 2 deletions runners/02_reference_to_parquet.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ref_hl_out <- glue('/Users/mjohnson/hydrofabric/v2.2/reference/conus_hydrolo
fl = as_sqlite(ref_gpkg, 'reference_flowline') %>%
select(id = comid,
toid = tocomid,
poi_id = POI_ID,
#poi_id = POI_ID,
terminalpa,
mainstemlp = levelpathi,
vpuid,
Expand Down Expand Up @@ -66,13 +66,16 @@ hl = as_sqlite(ref_gpkg, 'poi_data') %>%
filter(hl, hl_reference == "Gages", hl_link == "06752260") %>%
st_as_sf(coords = c("X", "Y"), crs = 5070) %>%
mapview::mapview()

filter(net, hl_uri == "Gages-06752260")
filter(hl, hl_uri == "Gages-06752260")

net = st_drop_geometry(div) %>%
mutate(id = divide_id, vpuid = NULL) %>%
full_join(st_drop_geometry(select(fl, -areasqkm)), by = "id") %>%
mutate(hf_id = id, topo = "fl-fl") %>%
left_join(select(hl, -vpuid, -X, -Y),
by = "poi_id",
by = "id",
relationship = "many-to-many")

mutate(div,
Expand Down
21 changes: 17 additions & 4 deletions runners/03_update_hydrolocations.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ gfv20 = open_dataset(glue("{source}/v2.2/reference/conus_hydrolocations")) %>%
relocate(all_of(schema)) %>%
distinct()

filter(gfv20, hl_reference == "Gages", hl_link == "06752260") %>%
st_as_sf(coords = c("X", "Y"), crs = 5070) %>%
mapview::mapview()

# RouteLink ---------------------------------------------------------------

rl_file = glue('/Users/mjohnson/hydrofabric/RouteLink_CONUS_309.nc')
Expand Down Expand Up @@ -321,7 +325,7 @@ lid <- read_sf(glue('{source}/nws_lid.gpkg')) |>

# Final ------------------------------------------------------------------

hl = rbindlist(list(rl_pois,
hl_fin = rbindlist(list(rl_pois,
nwmlake_pois,
nwm_res,
calib_poi,
Expand All @@ -341,16 +345,25 @@ hl = rbindlist(list(rl_pois,
left_join(distinct(select(ref_net, hf_id, mainstemlp, vpuid)),
by = "hf_id",
relationship = "many-to-many") %>%
distinct()
distinct() %>%
mutate(hl_uri = paste0(hl_reference, "-", hl_link))

filter(hl_fin, hl_reference == "Gages", hl_link == "06752260") %>%
st_as_sf(coords = c("X", "Y"), crs = 5070) %>%
mapview::mapview()

filter(hl_fin, hl_uri == 'Gages-06752260')

# Write Hydrolocation Table
hl %>%
hl_fin %>%
group_by(vpuid) %>%
arrow::write_dataset(glue("{source}/conus_hl"), version = 2.6)

"aws s3 sync /Users/mjohnson/hydrofabric/conus_hl s3://lynker-spatial/hydrofabric/conus_hl" %>%
system()

open_dataset(glue("{source}/conus_hl")) %>% collect()
open_dataset(glue("{source}/conus_hl")) %>%
filter(hl_uri == 'Gages-06752260') %>%
collect()


0 comments on commit b2e9d24

Please sign in to comment.