Build the NextGen data model from refactored + aggregated layers (nextgen phase)
Source:R/build_nextgen.R
nextgen_fabric.RdConsumes stage-1 (refactored + reconciled + hydrolocations) AND
stage-2 (out_vpu{id}.gpkg) artifacts; produces the ngen-ready
GeoPackage with model attributes and aspatial network.
Usage
nextgen_fabric(
vpuid,
fabric_dir,
fdr_path,
fac_path,
fallback_fdr_path = NULL,
fallback_fac_path = NULL,
out_dir,
coverage_min = 0.9,
threshold_m2 = 1000,
threshold_sqkm = 0.001,
gap_fill_area = 1000,
overlap_rule = "max-area",
n_cores = NULL,
hydraulics_path = NULL,
lakes_path = NULL,
lake_mask_path = NULL,
slope_parquet = NULL,
reference_gpkg = NULL,
verbose = FALSE
)Arguments
- vpuid
VPU identifier.
- fabric_dir
Path to the vpu working directory holding the refactored + aggregated fabric.
- fdr_path, fac_path
Raster paths (local or
/vsis3/...).- fallback_fdr_path, fallback_fac_path
Optional paths to a fallback FDR/FAC pair used when the primary returns NA.
NULLdisables the fallback (default). Ignored when equal to the primary paths.- out_dir
Parent output directory;
vpu_{vpuid}/is created.- coverage_min
Divide-coverage invariant + coalesce/clip floor (0-1).
- threshold_m2
fill_small_holesarea threshold on ngen divides (m^2).- threshold_sqkm
prune_ghost_dividesarea threshold (km^2).- gap_fill_area
Gap-fill area for
hfutils::clean_gpkg_layer(ngen phase).- overlap_rule
Divide overlap resolution rule.
- n_cores
Worker count for
repair_split_divides_at_pois.- hydraulics_path
Optional path to a RiverML channel table parquet, either its v2 output (e.g.
superconus_ml_attributes_v2.parquet) or the earlier channel-geometry table. When supplied, Step 6g computes flow attributes for bothflowpath_idandflowline_idand writesflowpath-attributesandflowline-attributeslayers to the ngen GeoPackage. Reaches with no match in the table fall back through a geomorphic proxy.NULLskips Step 6g (default).- lakes_path
Optional path to the NWM lakes GeoPackage (e.g.
nwm_lakes.gpkg). When supplied, Step 6h identifies the outlet flowline of each lake (minimumflowline_hydroseqamong COMIDs belonging to the lake), joins NWM lake attributes, and writes alakeslayer to the ngen GeoPackage. The reach ->lake_idmembership used for outlet fallback and member stamping comes fromlake_mask_path.NULLskips Step 6h (default).- lake_mask_path
Optional path to a lake-mask parquet: reach -> waterbody membership with integer columns
comid(reference flowline id) andwbareacomi(waterbody /lake_id). Required whenlakes_pathis supplied. The CONUS mask is materialized from NHDPlusV2 wbareacomi; oCONUS / superconus domains supply an equivalent with the same schema.- slope_parquet
Optional path to a per-reference-id slope parquet, passed to
finalize_data_model().NULL(default) takes slope fromhydraulics_pathwhen that table carries aslope_m_mcolumn, and otherwise leavesslopeNA.- reference_gpkg
Optional path to the reference fabric GeoPackage (source of member slope / divide geometry).
NULLdisables features needing it.- verbose
Propagated to internal helpers.