Title: | A Tool Used to Conduct Hypsometric Analysis of a Watershed |
---|---|
Description: | Functions for generating tables required for drawing and calculating hypsometric curves and hypsometric integrals. These functions accept as input the DEM of the region of interest (your watershed) and a spatial data frame file specifying delineation of sub-catchments within the watershed. They then generate output in the form of PNG images and HTML files contained in a folder named "HYPSO_OUTPUT" created in the current directory. S. K. Sharma, S. Gajbhiye, et al. (2018) <doi:10.1007/978-981-10-5801-1_19>. Omvir Singh, A. Sarangi, and Milap C. Sharma (2006) <doi:10.1007/s11269-008-9242-z>. James A. Vanderwaal and Herbert Ssegane (2013) <doi:10.1111/jawr.12089>. |
Authors: | Faustin GASHAKAMBA |
Maintainer: | Faustin GASHAKAMBA <[email protected]> |
License: | GPL-3 |
Version: | 0.2.0 |
Built: | 2025-02-13 04:14:25 UTC |
Source: | https://github.com/cran/hypsoLoop |
This function takes a categorical raster object and calculates the areas covered by each class within the raster.
calc_areas(x)
calc_areas(x)
x |
An object of class RasterLayer. |
The raster package's "area()" function normally returns the same raster where cell values have been replaced by their areas in Square Km. Using this function, the values of all cells of same class are aggregated and the raster is transformed into a data frame. If the CRS of the input raster is projected, then the area is calculated by multiplying the resolution of the raster by the count of cells for each class.
A data frame with one column representing the values of the classes of the raster and the other variable representing corresponding areas in Ha.
Faustin Gashakamba
calc_areas(lulcYanze)
calc_areas(lulcYanze)
This function tests whether the input supplied by the user are of the expected type (class), and are in the right form (overlap of extents and same projection).
check_arguments(x, y)
check_arguments(x, y)
x |
The input provided by the user for the x argument. |
y |
The input provided by the user for the y argument. |
There is no return value. If any error is found, the execution is just halted.
This function takes as input the DEM and sub-catchments boundaries and calls the hypsoTables function to produce the hypsometric tables. It then draws and prints out the hypsometric curves for each sub-catchment. Then, it fits a function to the table of each sub-cacthment and uses it to calculate the hypsometric integral. Finally, it summarizes the results in a well-formatted table and prints it out as CSV. All these results are stored in a folder called "HYPSO_OUTPUT" created in the current working directory.
drawHypsoCurves(x, y, print_result = FALSE)
drawHypsoCurves(x, y, print_result = FALSE)
x |
An object of class SpatialPolygonsDataFrame or simple features (sf). For instance, you can use RGDAL package's "readOGR()" function to create such an object from Shapefiles saved on disk. Alternatively, you can use sf's st_read() function to get a simple features object from the shapefile. NB: at least one column (attribute) named 'Name' should be present in the shapefile or input data frame. |
y |
An object of class RasterLayer. You can use the raster package to read GeoTIFF and other raster formats from disk. |
print_result |
A logical variable to decide whether the output folder will be created to contain the figures and summary table (CSV) or not. |
The elevation range of each sub-cacthment is divided into 30 contour intervals and the area covered by each contour interval is calculated. The result is put into tables (one table for each sub-catchment). This data is then used to construct the hypsometric curve through ggplot2. A 3rd polynomial function is then fitted to the normalized table and PolynomF package is used to calculate the area under the hypsometric curve (its integral). Finally, the integral values for each sub-catchment are compiled into a data frame that is exported as CSV.
A data frame containing the hypsometric integral for each sub-catchment along with other data such as maximum & minimum elevation.
Faustin Gashakamba [email protected]
drawHypsoCurves(watersheds, DEM) #Draw hypsographic curves of the sub-catchments in 'watersheds'.
drawHypsoCurves(watersheds, DEM) #Draw hypsographic curves of the sub-catchments in 'watersheds'.
This function accepts as input the DEM and sub-catchments boundaries and pre-process this data to extract the tables that are used to calculate the hypsographic curves and integral of these sub-catchments.
generateHypsoTables(x, y)
generateHypsoTables(x, y)
x |
An object of class SpatialPolygonsDataFrame or simple features (sf). For instance, you can use RGDAL package's "readOGR()" function to create such an object from Shapefiles saved on disk. Alternatively, you can use sf's st_read() function to get a simple features object from the shapefile. NB: at least one column (attribute) named 'Name' should be present in the shapefile or input data frame. |
y |
An object of class RasterLayer. You can use the raster package to read GeoTIFF and other raster formats from disk. |
The raster package's "crop()" and "mask()" functions are used to iteratively clip the DEM to each sub-catchment. For each sub-cacthment, the elevation range is divided into 30 equidistant contours. Then, the "area()" function is used to calculate the areas between each contour.
A list of length 2. The 1st element is a list of data frames, each representing the hypsometric tables for each sub-catchment. The 2nd element is a data frame with min & max elevation values for each sub-catchment.
Faustin Gashakamba [email protected]
This function tests whether the supplied vector input is a simple features (sf) object, if not, the object is converted using the st_as-sf() function.
raster_conversion(y)
raster_conversion(y)
y |
The input provided by the user for the y argument. |
the converted SpatRaster object
This function tests whether the supplied vector input is a simple features (sf) object, if not, the object is converted using the st_as-sf() function.
Vector_conversion(x)
Vector_conversion(x)
x |
The input provided by the user for the x argument. |
the converted simple features object
This data consists of a 30X30m-resolution digital elevation model (DEM) of Yanze, a small watershed located in north-west of Kigali City, Rwanda. The spatial reference system used by the coordinates of DEM is GCS_WGS_1984 with a D_WGS_1984 datum. The cell values are expressed in Meters with a minimum 1370m of and a maximum of 2241.
DEM
DEM
An S4 object of class stars
extent: 29.91865, 30.03865, -1.941896, -1.755507 (xmin, xmax, ymin, ymax) dimensions : 671, 432, 289872 (nrow, ncol, ncell)
This data consists of a raster representing the landuse in Yanze watershed, a small watershed located in north-west of Kigali City, Rwanda. he spatial reference system used by the coordinates of DEM is the WGS 84 UTM zone 35S - EPSG:32735. Each land use/land cover class is represented by its code as follows: 1 = Forest 2 = Open Areas or Grass 3 = Agriculture (Seasonal) 5 = Settlements and Buildings 6 = Water 10 = Sparse Forest 11 = Agriculture (Perennial)
lulcYanze
lulcYanze
An S4 object of class stars
extent: 824728, 838128, -214942.7, -194282.7 (xmin, xmax, ymin, ymax)
This data consists of the boundaries of sub-catchments of Yanze watershed, a small watershed located in north-west of Kigali City, Rwanda. The spatial reference system used by the coordinates of this SpatialPolygonsDataFrame is GCS_WGS_1984 with a D_WGS_1984 datum.
watersheds
watersheds
An S4 object of class simple features
extent: 29.91865, 30.03858, -1.755426, -1.941896 (xmin, xmax, ymin, ymax)
The id of each polygon
The name of each polygon
This data consists of a table containing the attributes of sub-catchment of Yanze watersehd.
watersheds_df
watersheds_df
a data frame.
Each rows represents a sub-catchment in yanze watershed, namely: Mulindi, cyonyonyo, and Yanze downstream.
The name of each sub-catchment