View source: R/function_CalculateRiverDistance.R
| CalculateRiverDistance | R Documentation |
Calculates the river distance between two SUBIDs along the routing network.
The distance is calculated by summing the RIVLEN values of the subbasins
between the two requested SUBIDs. The sign of the returned distance indicates
the direction of the routing: positive if SUBID1 is upstream of SUBID2,
and negative if SUBID1 is downstream of SUBID2.
CalculateRiverDistance(SUBID1, SUBID2, gd, bd = NULL)
SUBID1 |
Numeric or character. The first SUBID. |
SUBID2 |
Numeric or character. The second SUBID. |
gd |
A data frame containing HYPE geographical data (i.e. an imported 'GeoData.txt' file). Must contain the
columns |
bd |
Optional data frame containing HYPE branch data. Used by
|
The function first checks that both requested SUBIDs exist in gd and that
the RIVLEN column is available. It then uses AllDownstreamSubids() to
identify the downstream routing from the first SUBID.
If SUBID2 is downstream of SUBID1, the distance is returned as a positive
value. If SUBID1 is downstream of SUBID2, the routing direction is
reversed and the distance is returned as a negative value.
The distance is calculated by summing the RIVLEN values for the SUBIDs
between the two requested SUBIDs. The RIVLEN of the upstream SUBID itself
is not included in the calculation.
If no routing connection exists between the two SUBIDs, the function issues
a warning and returns NA.
A numeric value giving the river distance between SUBID1 and SUBID2.
The value is positive when SUBID1 is upstream of SUBID2 and negative when
SUBID1 is downstream of SUBID2. Returns NA if no routing connection
exists between the two SUBIDs.
AllDownstreamSubids()
AllUpstreamSubids()
# Read GeoData and BranchData files
gd <- ReadGeoData(
filename = system.file("demo_model", "GeoData.txt", package = "HYPEtools")
)
bd <- ReadGeoData(
filename = system.file("demo_model", "GeoData.txt", package = "HYPEtools")
)
# Calculate the river distance between two SUBIDs
CalculateRiverDistance(
SUBID1 = 3344,
SUBID2 = 3587,
gd = gd
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.