knitr::opts_chunk$set( collapse = TRUE, comment = "#>", warning = FALSE, fig.width = 7.1, fig.height = 6 )
Load HYPEtools Package and Import Files
# Load Package library(HYPEtools) # Get Path to HYPEtools Model Example Files model_path <- system.file("demo_model", package = "HYPEtools") # Import HYPE Model Files gd <- ReadGeoData(file.path(model_path, "GeoData.txt")) gcl <- ReadGeoClass(file.path(model_path, "GeoClass.txt"))
Look at names of Soil and Land Use Classes
# Read Comment in GeoClass.txt comment(gcl)
Summarize fractions for the whole drainage area upstream of the gauge.
# Select SUBID for which you want to summarize the upstream characteristics Qobs.sbd <- 3587 # Upstream soil fractions in percent sof <- as.numeric(UpstreamGroupSLCClasses(subid = Qobs.sbd, gd = gd, gc = gcl, type = "soil", progbar = FALSE)[, -1] * 100) # Show how many classes are in each soil category length(sof) # Calculate how many soil classes have a value greater than 0 sum(sof != 0) # Add names for soil categories names(sof) <- c("Fine soil", "Coarse soil") # Display the upstream soil percentages sof
Summarize fractions for the whole drainage area upstream of the gauge.
# Select SUBID for which you want to summarize the upstream characteristics Qobs.sbd <- 3587 # Upstream land use fractions in percent luf <- as.numeric(UpstreamGroupSLCClasses(subid = Qobs.sbd, gd = gd, gc = gcl, type = "landuse", progbar = FALSE)[, -1] * 100) # Show how many land use classes there are length(luf) # Calculate how many land use classes have a value greater than 0 sum(luf != 0) # Add names for land use categories names(luf) <- c("Water", "Coniferous", "Agriculture") # Display the upstream land use percentages luf
Plot fractions for the whole drainage area upstream of the gauge.
# Plot Upstream Soil Fractions barplot(sof, ylab = "Area (%)", names.arg = "", col = "red", ylim = c(0, 100), xlab = "Soil fraction") mtext(text = names(sof), side = 3, at = seq(.7, by = 1.2, length.out = 5), line = -.1, padj = .5, cex = .9, las = 3, adj = 1) mtext(Qobs.sbd, side = 1, adj = 0, font = 3) box() # Plot Upstream Land Use Fractions barplot(luf, ylab = "Area (%)", names.arg = "", col = "green", ylim = c(0, 100), xlab = "Land use fraction") mtext(text = names(luf), side = 3, at = seq(.7, by = 1.2, length.out = 8), line = -.1, padj = .5, cex = .9, las = 3, adj = 1) mtext(Qobs.sbd, side = 1, adj = 0, font = 3) box()
This summarizes the soil and land use fractions for the total upstream area for each subbasin.
# Get a vector of all subids in the model from GeoData sbd <- gd$SUBID # Summarize upstream soils sof.all <- UpstreamGroupSLCClasses(gd = gd, gcl = gcl, type = "soil", progbar = FALSE)[, -1] * 100 sof.all <- cbind("SUBID" = sbd, sof.all) sof.all # Summarize upstream land use luf.all <- UpstreamGroupSLCClasses(gd = gd, gcl = gcl, type = "landuse", progbar = FALSE)[, -1] * 100 luf.all <- cbind("SUBID" = sbd, luf.all) luf.all
This summarizes the soil and land use fractions within just each subbasin area.
# Summarize subbasin soils sof.sbd.all <- GroupSLCClasses(gd = gd, gcl = gcl, type = "soil", verbose = FALSE)[, -1] * 100 sof.sbd.all <- cbind("SUBID" = sbd, sof.sbd.all) sof.sbd.all # Summarize subbasin land use luf.sbd.all <- GroupSLCClasses(gd = gd, gcl = gcl, type = "landuse", verbose = FALSE)[, -1] * 100 luf.sbd.all <- cbind("SUBID" = sbd, luf.sbd.all) luf.sbd.all
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.