usgs-r / drb-network-prep Goto Github PK
View Code? Open in Web Editor NEWCode repo to prepare the river network for modeling in the Delaware River Basin
Code repo to prepare the river network for modeling in the Delaware River Basin
Even if omit_divergences = TRUE
, some reaches in p2_drb_comids_all_tribs
represent divergent reaches (where STREAMORDE != STREAMCALC
). It appears that these reaches are associated with PRMS/NHM segments included in drb_segs_spatial.
Add a step to get_intersecting_nhdplus_catchments()
to exclude these reaches when building the crosswalk table if omit_divergences = TRUE
.
> tar_load(p1_nhdv2reaches_sf)
> tar_load(p2_drb_comids_all_tribs)
> p2_drb_comids_all_tribs %>%
+ mutate(COMID = as.integer(COMID)) %>%
+ left_join(sf::st_drop_geometry(p1_nhdv2reaches_sf[,c("COMID","STREAMORDE","STREAMCALC")]), by = "COMID") %>%
+ filter(STREAMORDE != STREAMCALC) %>% pull(PRMS_segid) %>%
+ unique()
[1] "1256_1" "2137_1" "2138_1" "233_1" "249_1" "2757_1" "2758_1" "2765_1" "2766_1" "2767_1" "2797_1" "354_1" "355_1" "396_1" "593_1"
>
Create a gpkg file containing the NHDPlusV2 catchment polygons for the DRB. Related to #11.
Jake mentioned the need for universal ids in hru processing tasks (USGS-R/drb_gridmet_tools#11 (comment)). I was looking into this for the gridmet data. In the GFv1_catchments_edited.gpkg
file, there is an hru_id
column which seems like would serve the purpose of more "universal" identifier. A couple questions I have about this:
Is this hru_id_nat
?
I noticed that for 6 of the 867 hru's, there is no hru_id
. These are for the three segments that have been split (3_1/3_2, 51_1/51_2, 8_1/8_2). I'm wondering if we should still assign the original hru_id
to the *_1 segments and maybe to the *_2 segments too.
I'm wondering if the code to build the NHM - NHDPlusv2 crosswalk table could be made simpler and thus more readable by replacing traverse_nhd()
with some helpers from nhdplusTools
. Due to idiosyncrasies in the NHM v1.0 network this may not necessarily be a better solution to what we've got, but probably worth considering.
I was looking at the nhd catchments/flowlines in the DRB. Since these will likely be added to this repo, I wanted to make a note of something I found.
Of the 12970 nhd flowlines in the DRB, 460 do not have an associated catchment.
These 460 are all very small. Some cross over catchment boundaries.
Here are a couple samples (the red ones do not have catchments)
Here'e an overview of the lengths of the segs w/ and w/o catchments:
See here for code: https://gist.github.com/jsadler2/504067b814c2d2601e1241ddf3ad7a16
Omit special handling steps when identifying comid_cat
for the subset of segments defined in drb_segs_spatial
. See #15 for further details.
This means omitting:
drb_segs_spatial
from _targets.Rget_intersecting_nhdplus_catchments()
in 2_process/pair_nhd_catchments.Rpair_nhd_catchments
in 2_process/pair_nhd_catchments.RTo make GFV1_catchments_edited
more useful, we should add the hru_id_nat
in addition to the hru_id
There are PRMS segments where comid_down
, comid_seg
, or comid_cat
are zero-area COMIDs (i.e., with AREASQKM = 0
). From the drb-inland-salinity-ml, it would be ideal if all COMIDs had attributes. Check these instances of zero-area COMIDs and if possible, omit these from the crosswalk table.
In FY22, PUMP-ML projects used NHGFv1 to represent the river network fabric. Now that NHGFv2 has been released, how do these datasets compare in the DRB?
Add a function/target that computes the network adjacency matrix for the DRB NHDPlusV2 network, likely borrowing heavily from the calc_dist_matrices
function in delaware-model-prep.
When I started working on #17, I noticed that using p2_drb_comids_all_tribs
results in some notable "holes" in the network, i.e. places where we don't identify that COMID as one for which to grab the catchment polygon. Some of these result because of the way we use special handling to identify comid_cat
's for reaches within drb_segs_spatial
. But it also seems that divergent reaches have associated catchments. I don't think I appreciated that by omitting divergent reaches in the crosswalk table we'd also be impacting the catchments over which we may want to calculate HRU-scale attributes (e.g. as in the inland salinity project).
Here's an example, where the white "holes" are catchments associated with divergences.
Not all the geometries within p2_GFv1_catchments_edited_sf
are valid (e.g. all(st_is_valid(p1_catchments_edited_sf))
returns FALSE). See this PR in the inland salinity repo for further details.
Retain attribute seg_id_nat (in addition to regional segment/DRB segment identifiers) when writing crosswalk table.
I noticed some unexpected COMIDs are included in comid_cat
for at least one of the segments within drb_segs_spatial
. We currently identify these COMIDs using the NHD catchments that overlap the original PRMS HRU, so these extraneous COMIDs are being returned from the lines below in get_intersecting_nhdplus_catchments
:
# Download flowlines and VAA for COMIDs in nhd_cats_intrsct
nhd_flines_intrsct <- nhdplusTools::get_nhdplus(comid = c(nhd_cats_intrsct$featureid),
realization = 'flowline') %>%
# reformat variable names to uppercase
rename_with(.,toupper,id:enabled)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.