Validate a reference fabric before building from it
Source:R/check_reference_input.R
check_reference_input.RdA build inherits whatever its reference asserts. Two classes of input damage are silent at read time yet destroy the result:
Usage
check_reference_input(
reference_gpkg,
layer = "flowpaths",
id = "flowpath_id",
toid = "flowpath_toid",
min_resolved = 0.9,
strict = TRUE
)Arguments
- reference_gpkg
Path to a reference fabric GeoPackage.
- layer
Flowpaths layer name. Default
"flowpaths".- id, toid
Identifier and downstream-identifier column names.
- min_resolved
Minimum share of non-terminal
toidvalues that must name an existingid. Terminals (toid0 orNA) are excluded from the denominator, since they legitimately point nowhere.- strict
If
TRUE(default) a failure raises an error; ifFALSEit warns and returns the findings.
Details
Truncated identifiers. GeoPackage
MEDIUMINTcolumns are 32-bit (OFTInteger). A 14-digit NHD-HR identifier written into one wraps modulo 2^32, soflowpath_toidbecomes a negative or unrelated number whileflowpath_id(64-bitINTEGER) survives. Nothing errors; the topology is simply gone.Unresolvable topology. When
flowpath_toidnames identifiers that are not present inflowpath_id, aggregation finds no connected reaches and degenerates to one flowpath per reach: the fabric is produced, passes its invariants, and is silently unaggregated.
Both are cheap to detect and expensive to discover afterwards, so this runs before a build rather than after.