Function to find all SUBIDs of upstream sub-catchments for a single sub-catchment.
AllUpstreamSubids(
subid,
gd,
bd = NULL,
sort = FALSE,
get.weights = FALSE,
write.arcgis = FALSE
)
If get.weights
is FALSE
, AllUpstreamSubids
returns a vector of SUBIDs, otherwise a two-column data frame with SUBIDs in
the first, and flow weight fractions in the second column.
SUBID of a target sub-catchment (must exist in gd
).
A data frame, containing 'SUBID' and 'MAINDOWN' columns, e.g. an imported 'GeoData.txt' file. Mandatory argument. See 'Details'.
A data frame, containing 'BRANCHID' and 'SOURCEID' columns, and 'MAINPART' with argument get.weights
,
e.g. an imported 'BranchData.txt' file. Optional argument.
Logical. If TRUE
, the resulting upstream SUBID vector will be sorted according to order in argument gd
, i.e. in
downstream order for a working GeoData table.
Logical. If TRUE
, flow weights are computed along the upstream SUBID sequence. See details.
Logical. If TRUE
, a string containing an SQL expression suitable for ArcGIS's
'Select By Attributes' feature will be written to the clipboard.
AllUpstreamSubids
finds all upstream SUBIDs of a given SUBID (including itself but not
including potential irrigation links or groundwater flows) using GeoData columns 'SUBID' and 'MAINDOWN', i.e the full upstream catchment.
If a BranchData file is provided, the function will also include upstream areas which are connected through an upstream bifurcation. The
results can be directly used as 'partial model setup file' ('pmsf.txt') using the export function WritePmsf
.
If argument get.weights
is set to TRUE
, weighting fractions are returned along with upstream SUBIDs. The fractions are based
on column 'MAINPART' in argument bd
. The function considers fractions from bifurcation branches which flow into the basin, and
fractions where bifurcation branches remove discharge from the basin. Fractions are incrementally updated, i.e. nested bifurcation fractions
are multiplied.
For details on bifurcation handling in HYPE, see the HYPE online documentation for BranchData.txt.
UpstreamGeoData
, AllDownstreamSubids
te <- ReadGeoData(filename = system.file("demo_model", "GeoData.txt", package = "HYPEtools"))
AllUpstreamSubids(subid = 63794, gd = te)
Run the code above in your browser using DataLab