Learn R Programming

spNetwork (version 0.2.1)

simplify_network: Simplify a network

Description

Simplify a network by applying two corrections: Healing edges and Removing mirror edges (experimental).

Usage

simplify_network(
  lines,
  digits = 3,
  heal = TRUE,
  mirror = TRUE,
  keep_shortest = TRUE,
  verbose = TRUE
)

Arguments

lines

A SpatialLinesDataFrame

digits

An integer indicating the number of digits to keep in coordinates

heal

A boolean indicating if the healing operation must be performed

mirror

A booleans indicating if the mirror edges must be removed

keep_shortest

A boolean, if TRUE, then the shortest line is keeped from mirror edges. if FALSE, then the longest line is keeped.

verbose

A boolean indicating if messages and progressbar should be displayed

Value

A SpatialLinesDataFrame

Details

Healing is the operation to merge two connected linestring if the are intersecting at one extremity and do not intersect any other linestring. It helps to reduce the complexity of the network and thus can reduce calculation time. Removing mirror edges is the operation to remove edges that have the same extremities. If two edges start at the same point and end at the same point, they do not add information in the network and one can be removed to simplify the network. One can decide to keep the longest of the two edges or the shortest. NOTE: the edge healing does not consider lines directions currently!

Examples

Run this code
# NOT RUN {
library(spNetwork)
networkgpkg <- system.file("extdata", "networks.gpkg",package = "spNetwork", mustWork = TRUE)
lines <- mtl_network <- rgdal::readOGR(networkgpkg,layer="mtl_network",verbose = FALSE)
edited_lines <- simplify_network(lines, digits = 3, verbose = FALSE)
# }

Run the code above in your browser using DataLab