Skip to contents

Will find every ID of all segments upstream of the segment selected

Usage

TNETutils_findUpstreamSegment(
  segments,
  ID_start,
  ID_stop = NULL,
  add_IDstart = FALSE
)

Arguments

segments

data.frame All segments in the shapefile. must have the following columns:

gid_newID of the Topage segment
ID_ND_INIID of the initial node of the segment.
ID_ND_FINID of the final node of the segment.
ID_start

numeric ID of the segment to start the search

ID_stop

numeric ID of segments to not include in the search. all IDs upstream of the of those ones will be ignored.

add_IDstart

bool If TRUE, the ID_start segment will be included in the results. If FALSE, it will not be included (only thoses upstream of it will be exported)

Value

a vector with all segments ID found

Examples

# Read exemple shapefile
exemple_files <- TNETutils_openExempleData()
shape_data <- st_read(exemple_files$Shapefile_segments)
#> Reading layer `TestNetwork_Ardiere' from data source 
#>   `/tmp/RtmpK8SS06/temp_libpatha1da1c3788c3/TnetRUI/extdata/TestNetwork_Ardiere.shp' 
#>   using driver `ESRI Shapefile'
#> Simple feature collection with 121 features and 65 fields
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: 814849.3 ymin: 6559414 xmax: 824534.9 ymax: 6568750
#> Projected CRS: RGF93 v1 / Lambert-93

# found all IDs upstream of the segment 1671262
ID_found <- TNETutils_findUpstreamSegment(segments = shape_data, ID_start=1671262)
ID_found
#> [1] 167126203 167126202 167126201

# found all IDs upstream of the segment 1671262 (including 1671262)
ID_found <- TNETutils_findUpstreamSegment(segments = shape_data, ID_start=1671262,add_IDstart = TRUE)
ID_found
#> [1]   1671262 167126203 167126202 167126201