build_graph_directed: Directed network generation

Description Usage Arguments Details Value Examples

View source: R/graph_functions.R

Description

Generate a directed igraph object from a SpatialLinesDataFrame.

Usage

1
build_graph_directed(lines, digits, line_weight, direction, attrs = FALSE)

Arguments

lines

A SpatialLinesDataFrame

digits

The number of digits to keep from the coordinates

line_weight

The name of the column giving the weight of the lines

direction

A column name indicating 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"

attrs

A boolean indicating if the original lines' attributes should be stored in the final object

Details

This function can be used to generate a directed graph object (igraph object). It uses the coordinates of the linestrings extremities to create the nodes of the graph. This is why the number of digits in the coordinates is important. Too high a precision (high number of digits) might break some connections. The column used to indicate directions can only have the following values: "FT" (From-To), "TF" (To-From) and "Both".

Value

A list containing the following elements:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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")
graph_result <- build_graph_directed(lines = mtl_network_directed,
        digits = 2,
        line_weight = "length",
        direction = "direction",
        attrs = TRUE)

spNetwork documentation built on Oct. 30, 2021, 5:06 p.m.