lines_direction: Unify lines direction

View source: R/geometrical_functions_sf.R

lines_directionR Documentation

Unify lines direction

Description

A function to deal with the directions of lines. It ensures that only From-To situation are present by reverting To-From lines. For the lines labelled as To-From, the order of their vertices is reverted.

Usage

lines_direction(lines, field)

Arguments

lines

A sf object with linestring type geometries

field

Indicate a field giving information about authorized travelling direction on lines. if NULL, then all lines can be used in both directions. Must be the name of a column otherwise. The values of the column must be "FT" (From - To), "TF" (To - From) or "Both".

Value

A sf object with linestring type geometries

Examples

data(mtl_network)
mtl_network$length <- as.numeric(sf::st_length(mtl_network))
mtl_network$direction <- "Both"
mtl_network[6, "direction"] <- "TF"
mtl_network_directed <- lines_direction(mtl_network, "direction")

spNetwork documentation built on June 22, 2024, 9:40 a.m.