Compute Drain area using WhiteBox
Source:R/TNETshape_computeAreaDrain.R
TNETshape_computeAreaDrain.Rd
This function will compute drain area of each segment using WhiteBox algorithms. Confluences nodes are mooved upstream with TNETshape_computeNdAreaDrain()
.
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()
Details
Whitebox algorithms use in this function are the following: (in that order)
1 - Prepare the DEM for computations
wbt_fill_depressions(): To fill all depressions in the shapefile
wbt_fill_burn(): To burn the river network in the shapefile
2- Compute flow accumulations for each DEM pixel
wbt_d8_pointer(): To compute the flow direction of each pixel
wbt_d8_flow_accumulation(): To count how many pixels are upstream
This is used to extract total drain area on each segments
3- Snap nodes on rivers
TNETshape_computeNdAreaDrain()
: To create one node for each segments.wbt_snap_pour_points(): Snap on the pixel with the most flow accumulation (to be on a river)
4- Compute sub Watershed drain area (area drain only by the studied segment)
wbt_watershed(): Compute all sub watershed area
wbt_raster_area(): convert ID into drain area
wbt_extract_raster_values_at_points(): Extract D8_flow_accumulation and raster_area on every Nodes, to have total drain area and sub-watershed drain area
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)
#>
Décalage des noeuds [ ] 0%
Décalage des noeuds [> ] 2%
Décalage des noeuds [> ] 5%
Décalage des noeuds [> ] 8%
Décalage des noeuds [=> ] 10%
Décalage des noeuds [=> ] 12%
Décalage des noeuds [==> ] 15%
Décalage des noeuds [==> ] 18%
Décalage des noeuds [===> ] 20%
Décalage des noeuds [===> ] 22%
Décalage des noeuds [====> ] 25%
Décalage des noeuds [====> ] 28%
Décalage des noeuds [=====> ] 30%
Décalage des noeuds [=====> ] 32%
Décalage des noeuds [======> ] 35%
Décalage des noeuds [======> ] 38%
Décalage des noeuds [=======> ] 40%
Décalage des noeuds [=======> ] 42%
Décalage des noeuds [========> ] 45%
Décalage des noeuds [========> ] 48%
Décalage des noeuds [=========> ] 50%
Décalage des noeuds [=========> ] 52%
Décalage des noeuds [==========> ] 55%
Décalage des noeuds [==========> ] 57%
Décalage des noeuds [===========> ] 60%
Décalage des noeuds [===========> ] 62%
Décalage des noeuds [============> ] 65%
Décalage des noeuds [============> ] 68%
Décalage des noeuds [=============> ] 70%
Décalage des noeuds [=============> ] 72%
Décalage des noeuds [==============> ] 75%
Décalage des noeuds [==============> ] 78%
Décalage des noeuds [===============> ] 80%
Décalage des noeuds [===============> ] 82%
Décalage des noeuds [================> ] 85%
Décalage des noeuds [================> ] 88%
Décalage des noeuds [=================> ] 90%
Décalage des noeuds [=================> ] 92%
Décalage des noeuds [==================> ] 95%
Décalage des noeuds [==================> ] 98%
Décalage des noeuds [====================] 100%
#> Problems on drain area calculations was found on 2 segments:
#> 2 segments have a drainage area exceeding 40% of their upstream segment. (Threshold_limit)
#> All affected segments are saved in Area_problem.shp shapefile.
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...