Skip to contents

This function will compute drain area of each segment using WhiteBox algorithms. Confluences nodes are mooved upstream with TNETshape_computeNdAreaDrain().

Usage

TNETshape_computeAreaDrain(path_DEM, path_segments, path_node, export_file,ID_special = NULL)

Arguments

path_DEM

Path to the raster DEM used for drain area calculation.

path_segments

Path to the shapefile with segments to merge.

path_node

Path to the shapefile with all segments nodes.

export_file

Path to the shapefile with results to create.

ID_special

paste to TNETshape_computeNdAreaDrain()

Value

None

Details

Whitebox algorithms use in this function are the following: (in that order)

1 - Prepare the DEM for computations

2- Compute flow accumulations for each DEM pixel

This is used to extract total drain area on each segments

3- Snap nodes on rivers

4- Compute sub Watershed drain area (area drain only by the studied segment)

This is used to extract sub watershed drain area on each segments

Here is a figure on how sub-watershed area drain are calculated:

Examples

## Read test files
shape_name <- system.file("extdata","TestNetwork_Ardiere.shp", package = "TnetRUI")
shapeND_name <- system.file("extdata","TestNetwork_ND_Ardiere.shp", package = "TnetRUI")
DEM_name <- system.file("extdata","DEM_Ardiere.tif", package = "TnetRUI")

#run computation
result_shape <- "test/TestNetwork_areaDrain.shp"
TNETshape_computeAreaDrain(path_DEM = DEM_name,
                           path_segments = shape_name,
                           path_node = shapeND_name,
                           export_file = result_shape)
#> Warning: `/home/ghevin/Documents/T-NET/Code/TnetRUI/public/reference' not recognized as a supported file format. (GDAL error 4)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'res': Cannot create a RasterLayer object from this file.

data_result <- st_read(result_shape,quiet = TRUE)
data_result[1:5,c('gid_new','areaTot','areaSbv')]
#> Simple feature collection with 5 features and 3 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: 815250.2 ymin: 6562288 xmax: 823552 ymax: 6566542
#> Projected CRS: RGF93 v1 / Lambert-93
#>   gid_new  areaTot areaSbv                       geometry
#> 1  226527   813000  813000 LINESTRING (815339.3 656457...
#> 2  484239  1564300  934300 LINESTRING (819583.5 656236...
#> 3  506993  1151400  409400 LINESTRING (815250.2 656652...
#> 4  521815   824400  317800 LINESTRING (823552 6565477,...
#> 5  719833 55986500  527000 LINESTRING (822789.3 656266...