Learn R Programming

spNetwork (version 0.2.1)

lines_direction: 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 SpatialLinesDataFrame

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 SpatialLinesDataFrame

Examples

Run this code
# NOT RUN {
networkgpkg <- system.file("extdata", "networks.gpkg", package = "spNetwork", mustWork = TRUE)
mtl_network <- rgdal::readOGR(networkgpkg,layer="mtl_network", verbose=FALSE)
mtl_network$length <- rgeos::gLength(mtl_network, byid = TRUE)
mtl_network$direction <- "Both"
mtl_network[6, "direction"] <- "TF"
mtl_network_directed <- lines_direction(mtl_network, "direction")
# }

Run the code above in your browser using DataLab