Find all segments ID upstream of a given segment
Source:R/TNETutils_findUpstreamSegment.R
TNETutils_findUpstreamSegment.Rd
Will find every ID of all segments upstream of the segment selected
Arguments
- segments
data.frame All segments in the shapefile. must have the following columns:
gid_new
ID of the Topage segment ID_ND_INI
ID of the initial node of the segment. ID_ND_FIN
ID 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
, theID_start
segment will be included in the results. IfFALSE
, it will not be included (only thoses upstream of it will be exported)
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