UpstreamGroupSLCClasses: Calculate area-weighted upstream averages of grouped SLC...

View source: R/function_UpstreamGroupSLCClasses.R

UpstreamGroupSLCClassesR Documentation

Calculate area-weighted upstream averages of grouped SLC class fractions.

Description

Function to calculate averages of grouped SLC class fractions calculated from imported GeoData.txt and GeoClass.txt or any other user-defined grouping.

Usage

UpstreamGroupSLCClasses(
  subid = NULL,
  gd,
  bd = NULL,
  gcl = NULL,
  type = c("landuse", "soil", "crop"),
  group = NULL,
  signif.digits = 3,
  progbar = TRUE
)

Arguments

subid

Integer vector of SUBIDs for which to calculate upstream properties (must exist in gd). If NULL (default), upstream areas for all SUBIDs will be calculated.

gd

A data frame containing a column with SUBIDs and a column with areas, e.g. an imported 'GeoData.txt' file imported with ReadGeoData.

bd

A data frame, containing 'BRANCHID' and 'SOURCEID' columns, e.g. an imported 'BranchData.txt' file. Optional argument.

gcl

Data frame containing columns with SLCs and corresponding land use and soil class IDs, typically a 'GeoClass.txt' file imported with ReadGeoClass. Must be provided if no group argument is given.

type

Keyword character string for use with gcl. Type of grouping index, choice of "landuse", "soil", and/or "crop", can be abbreviated.

group

Integer vector, of same length as number of SLC classes in gd. Alternative grouping index specification to gcl + type.

signif.digits

Integer, number of significant digits to round upstream SLCs to. See also signif. Set to NULL to prevent rounding.

progbar

Logical, display a progress bar while calculating SLC class fractions. Adds overhead to calculation time but useful when subid is NULL or contains many SUBIDs.

Details

UpstreamGroupSLCClasses calculates area-weighted upstream averages of CropID fractions from SLC class fractions in a GeoData table and corresponding grouping columns in a GeoClass table or a user-provided vector. Upstream calculations include branch connections in case of stream bifurcations but not potential irrigation links or groundwater flows. Averages are weighted by sub-catchment area.

The function builds on GroupSLCClasses, which provides grouped sums of SLC classes for several or all sub-basins in a GeoData dataframe.

Value

UpstreamGroupSLCClasses returns a data frame with SUBIDs in the first column, and upstream group fractions in the following columns.

Note

UpstreamGroupSLCClasses expects SLC class columns in argument gd to be ordered in ascending order.

See Also

GroupSLCClasses UpstreamSLCClasses UpstreamGeoData SumUpstreamArea AllUpstreamSubids

Examples

# Import source data
te1 <- ReadGeoData(filename = system.file("demo_model", "GeoData.txt", package = "HYPEtools"))
te2 <- ReadGeoClass(filename = system.file("demo_model", "GeoClass.txt", package = "HYPEtools"))
# Upstream land use fractions for single SUBID
UpstreamGroupSLCClasses(subid = 63794, gd = te1, gcl = te2, type = "landuse", progbar = FALSE)
# Upstream soil fraction for all SUBIDs in GeoData
UpstreamGroupSLCClasses(gd = te1, gcl = te2, type = "soil")


HYPEtools documentation built on Sept. 11, 2024, 8:34 p.m.