Build an aspatial long-form network crosswalk
Source:R/build_aspatial_network.R
build_aspatial_network.RdReplaces the spatial network layer in a hydrofabric GeoPackage with an
aspatial attribute table keyed on (flowline_id, reference_id), one row
per sub-flowline x reference-COMID member. The table is rebuilt from the
flowlines layer and the reconciled-group memberships so it always matches
the trimmed topology produced by extend_flowpaths_to_mainstem:
flowlines on a flowpath's mainstem levelpathid keep the mainstem's
flowpath_id; flowlines on absorbed tributaries (different levelpathid)
report a synthetic fp-t<levelpathid> identity and inherit the mainstem's
downstream nexus as their flowpath_toid.
Output columns:
flowpath_id,flowpath_toid: aggregated flowpath topologymainstem_id: levelpathid of the flowpath's mainstem; group all flowlines on the same mainstem channelis_mainstem: TRUE when this flowline is on the flowpath's mainstem (levelpathid == mainstem_id); FALSE for absorbed tributariesflowline_id,flowline_toid: split-segment topologyreference_id: originating reference COMIDreference_percent: share of reference NHD length represented by this flowline's reconciled grouppoi_id: aggregation POI (nullable)hydrolocation_id:hl_idfrom hydrolocationsdivide_id,divide_areasqkm: divide this flowpath drains (all flowlines in a flowpath, mainstem and tributary: carry the samedivide_id)flowline_area: drainage area at flowline outlet (from FAC extraction)
Usage
build_aspatial_network(
gpkg,
refactored = NULL,
reconciled = NULL,
hydrolocations = NULL,
verbose = FALSE
)Arguments
- gpkg
Path to the ngen GeoPackage produced by
nextgen_from_gpkg.- refactored
sfof refactored flowlines fromrefactor_flowlines(out$refactored). Used to computereference_percentper reference COMID.- reconciled
sfof reconciled flowlines (out$reconciled): must containIDandmember_flowpath_id. Used to map each flowline's levelpathid back to the reference COMIDs it represents.- hydrolocations
sfof hydrolocations withpoi_idandhl_id, or path to a gpkg with ahydrolocationslayer. IfNULL,hydrolocation_idis sourced from theeventslayer if present.- verbose
If TRUE, emit a rich breakdown: row class counts, tributary-flowline share, reference_percent distribution, hydrolocation match rate, divide-area / flowline-area summaries. Default FALSE.