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:

gidID of the Topage segment
ND_INIID of the initial node of the segment.
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()
#>  Downloading DataTnetRUI...
#>  Downloading DataTnetRUI... [4.3s]
#> 
shape_data <- st_read(exemple_files$Shapefile_segments)
#> Reading layer `TestNetwork_Ardiere' from data source 
#>   `/tmp/RtmpouDjLp/temp_libpath55b3659c595f/TnetRUI/datatnetrui-v1.0/data/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)
#> Error in `[.data.frame`(x, i, j, drop = drop): undefined columns selected
ID_found
#> Error: object 'ID_found' not found

# found all IDs upstream of the segment 1671262 (including 1671262)
ID_found <- TNETutils_findUpstreamSegment(segments = shape_data, ID_start=1671262,add_IDstart = TRUE)
#> Error in `[.data.frame`(x, i, j, drop = drop): undefined columns selected
ID_found
#> Error: object 'ID_found' not found