Load HYPEtools Package and Import Files
Look at names of Soil and Land Use Classes
# Read Comment in GeoClass.txt
comment(gcl)
#> [1] "!Landuses: 1=Water; 2=Coniferous forest; 3=Agricultural land\t\t\t\t\t\t\t\t\t\t\t\t\t"
#> [2] "!Soils: 1=Fine soil; 2=Coarse soil\t\t\t\t\t\t\t\t\t\t\t\t\t"
#> [3] "!Combination\tLanduse\tSoil\tCropid-main\tCropid-2nd\tRotation\tVegetationstyp\tSpecial-class\tTile-depth\tDrain-depth\t#Soil-layers\tDepth1\tDepth2\tDepth3"
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)
#> [1] 2
# Calculate how many soil classes have a value greater than 0
sum(sof != 0)
#> [1] 2
# Add names for soil categories
names(sof) <- c("Fine soil", "Coarse soil")
# Display the upstream soil percentages
sof
#> Fine soil Coarse soil
#> 95.30 4.74
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)
#> [1] 3
# Calculate how many land use classes have a value greater than 0
sum(luf != 0)
#> [1] 3
# Add names for land use categories
names(luf) <- c("Water", "Coniferous", "Agriculture")
# Display the upstream land use percentages
luf
#> Water Coniferous Agriculture
#> 7.13 81.90 10.90
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
#> SUBID soil_1 soil_2
#> 1 3344 84.8 15.3000
#> 2 3396 99.9 0.0623
#> 3 3407 99.8 0.1610
#> 4 3466 90.3 9.6900
#> 5 3558 99.9 0.1090
#> 6 3555 99.4 0.5550
#> 7 3607 100.0 0.0000
#> 8 63804 92.4 7.6200
#> 9 63931 96.7 3.3200
#> 10 3564 96.6 3.4200
#> 11 3581 93.6 6.3600
#> 12 3547 95.0 4.9800
#> 13 3594 95.3 4.7300
#> 14 40556 94.0 6.0400
#> 15 40541 94.4 5.6400
#> 16 3486 94.6 5.4000
#> 17 3361 94.7 5.3000
#> 18 3427 96.2 3.8200
#> 19 3435 95.7 4.3500
#> 20 3432 95.2 4.8000
#> 21 63794 94.9 5.1300
#> 22 63938 98.3 1.7500
#> 23 63937 95.2 4.8300
#> 24 3532 95.3 4.7000
#> 25 3587 95.3 4.7400
# 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
#> SUBID landuse_1 landuse_2 landuse_3
#> 1 3344 1.30 85.2 13.600
#> 2 3396 10.80 74.2 15.000
#> 3 3407 10.70 73.6 15.800
#> 4 3466 3.89 80.2 15.900
#> 5 3558 26.10 73.4 0.497
#> 6 3555 11.80 83.7 4.500
#> 7 3607 7.80 91.3 0.920
#> 8 63804 6.73 84.1 9.200
#> 9 63931 12.70 81.3 6.060
#> 10 3564 12.60 81.2 6.180
#> 11 3581 3.18 90.0 6.860
#> 12 3547 7.33 86.3 6.400
#> 13 3594 7.04 86.9 6.080
#> 14 40556 6.25 84.6 9.200
#> 15 40541 6.71 83.8 9.450
#> 16 3486 6.55 83.4 10.000
#> 17 3361 14.00 85.3 0.745
#> 18 3427 11.60 87.8 0.593
#> 19 3435 12.50 85.1 2.450
#> 20 3432 8.54 84.0 7.440
#> 21 63794 6.66 83.3 10.000
#> 22 63938 7.70 80.4 11.900
#> 23 63937 6.75 83.1 10.200
#> 24 3532 7.18 82.0 10.800
#> 25 3587 7.13 81.9 10.900
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
#> SUBID AREA soil_1 soil_2
#> 1 3344 2012608500 84.7500 15.2501
#> 2 3396 1112100200 99.9376 0.0623
#> 3 3407 10551800 89.4554 10.5444
#> 4 3466 2359837800 90.5252 9.4750
#> 5 3558 154308900 99.8914 0.1087
#> 6 3555 187596400 99.0778 0.9220
#> 7 3607 1563873200 100.0000 0.0000
#> 8 63804 853734600 92.3847 7.6151
#> 9 63931 1762503100 95.8143 4.1858
#> 10 3564 14564400 69.1240 30.8759
#> 11 3581 6261965800 93.6349 6.3648
#> 12 3547 615319700 98.4508 1.5492
#> 13 3594 1226245300 97.5376 2.4621
#> 14 40556 3592919600 94.5337 5.4660
#> 15 40541 1632334200 99.7367 0.2632
#> 16 3486 1073738400 99.6694 0.3307
#> 17 3361 1070852700 94.6982 5.3018
#> 18 3427 480763600 99.4852 0.5149
#> 19 3435 1216238400 94.9739 5.0261
#> 20 3432 1739028400 94.4824 5.5178
#> 21 63794 1259415200 98.8926 1.1073
#> 22 63938 2913067100 98.2519 1.7482
#> 23 63937 7209200 99.7633 0.2366
#> 24 3532 1098516200 99.5008 0.4992
#> 25 3587 231451000 88.2830 11.7169
# 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
#> SUBID AREA landuse_1 landuse_2 landuse_3
#> 1 3344 2012608500 1.2984 85.1508 13.5509
#> 2 3396 1112100200 10.7671 74.2386 14.9942
#> 3 3407 10551800 0.0000 2.7361 97.2637
#> 4 3466 2359837800 2.8875 79.2264 17.8863
#> 5 3558 154308900 26.0620 73.4415 0.4966
#> 6 3555 187596400 0.0000 92.2010 7.7988
#> 7 3607 1563873200 7.8028 91.2776 0.9196
#> 8 63804 853734600 6.7265 84.0698 9.2035
#> 9 63931 1762503100 19.8918 71.0023 9.1060
#> 10 3564 14564400 0.0000 59.9522 40.0477
#> 11 3581 6261965800 3.1752 89.9599 6.8646
#> 12 3547 615319700 13.4997 83.4072 3.0931
#> 13 3594 1226245300 4.3993 92.3861 3.2143
#> 14 40556 3592919600 6.6157 83.2779 10.1061
#> 15 40541 1632334200 12.8052 74.3974 12.7973
#> 16 3486 1073738400 3.2067 73.8250 22.9684
#> 17 3361 1070852700 13.9634 85.2920 0.7446
#> 18 3427 480763600 6.2788 93.4668 0.2545
#> 19 3435 1216238400 13.6581 81.5245 4.8174
#> 20 3432 1739028400 2.2440 82.3727 15.3835
#> 21 63794 1259415200 2.0353 79.5062 18.4584
#> 22 63938 2913067100 7.6999 80.3565 11.9437
#> 23 63937 7209200 0.0000 78.0271 21.9728
#> 24 3532 1098516200 20.0171 49.3721 30.6108
#> 25 3587 231451000 0.0000 74.7462 25.2537