@@ -423,7 +423,7 @@ realign_topology = function(network_list,
423
423
# ' @export
424
424
425
425
apply_nexus_topology = function (gpkg ,
426
- vpu = NULL ,
426
+ vpu = NA ,
427
427
nexus_prefix = " nex-" ,
428
428
terminal_nexus_prefix = " tnx-" ,
429
429
coastal_nexus_prefix = " cnx-" ,
@@ -454,9 +454,12 @@ apply_nexus_topology = function(gpkg,
454
454
term_add = term_filter
455
455
}
456
456
457
- if (! is.null(vpu )) { ngen_flows $ topo $ vpu = as.character(vpu ) }
457
+ ngen_flows $ topo $ vpuid = as.character(vpu )
458
+
459
+ ngen_flows $ nexus $ vpuid = as.character(vpu )
458
460
459
461
ngen_flows $ flowpaths = ngen_flows $ flowpaths %> %
462
+ mutate(vpuid = as.character(vpu )) | >
460
463
select(id , toid ,
461
464
mainstem , order , hydroseq ,
462
465
lengthkm , areasqkm , tot_drainage_areasqkm ,
@@ -465,6 +468,7 @@ apply_nexus_topology = function(gpkg,
465
468
contains(" vpu" ))
466
469
467
470
ngen_flows $ divides = ngen_flows $ divides %> %
471
+ mutate(vpuid = as.character(vpu )) | >
468
472
select(divide_id , toid , type , ds_id , areasqkm , contains(" vpu" )) %> %
469
473
left_join(st_drop_geometry(select(ngen_flows $ flowpaths , id , divide_id , lengthkm , tot_drainage_areasqkm )), by = " divide_id" ) %> %
470
474
mutate(areasqkm = add_areasqkm(. ),
@@ -493,12 +497,12 @@ apply_nexus_topology = function(gpkg,
493
497
internal_nexus_prefix = internal_nexus_prefix ) %> %
494
498
full_join(st_drop_geometry(select(ngen_flows $ flowpaths ,
495
499
has_divide ,
496
- id , divide_id ,
500
+ id ,
501
+ divide_id ,
497
502
lengthkm ,
498
503
tot_drainage_areasqkm ,
499
504
mainstem ,
500
- has_divide ,
501
- contains(" vpu" ))),
505
+ has_divide )),
502
506
by = " id" ,
503
507
multiple = " all" ) %> %
504
508
full_join(st_drop_geometry(select(ngen_flows $ divides , divide_id , areasqkm , n2 = type )), by = " divide_id" ) %> %
@@ -528,16 +532,16 @@ apply_nexus_topology = function(gpkg,
528
532
filter(complete.cases(. )) %> %
529
533
left_join(select(st_drop_geometry(ngen_flows $ divides ), divide_id , toid ), by = ' divide_id' ) %> %
530
534
left_join(select(tmp , - id ), by = ' divide_id' ) %> %
531
- mutate(vpu = as.character(vpu ),
535
+ mutate(vpuid = as.character(vpu ),
532
536
poi_id = as.integer(poi_id ))
533
537
534
538
535
539
ngen_flows $ network = filter(network , ! type %in% c(c(' coastal' , " internal" ))) %> %
536
- left_join(select(tmp ,id , hf_source , hf_id , hf_id_part , hydroseq ), by = ' id' , relationship = " many-to-many" ) %> %
540
+ left_join(select(tmp , id , hf_source , hf_id , hf_id_part , hydroseq ), by = ' id' , relationship = " many-to-many" ) %> %
537
541
bind_rows(sinks ) %> %
538
- select(id , toid , divide_id , ds_id , mainstem , poi_id , hydroseq , poi_id , # hl_uri,
542
+ select(id , toid , divide_id , ds_id , mainstem , poi_id , hydroseq , # hl_uri,
539
543
hf_source , hf_id , lengthkm , areasqkm , tot_drainage_areasqkm ,
540
- type , vpu )
544
+ type , vpuid )
541
545
}
542
546
543
547
# if(layer_exists(gpkg, "hydrolocations")){
0 commit comments