make_edges_valid: Match edge geometries to their incident node locations

View source: R/edge.R

make_edges_validR Documentation

Match edge geometries to their incident node locations

Description

This function makes invalid edges valid by modifying either edge or node geometries such that the boundary points of edge linestring geometries always match the point geometries of the nodes that are specified as their incident nodes by the *from* and *to* columns.

Usage

make_edges_valid(x, preserve_geometries = FALSE)

Arguments

x

An object of class sfnetwork.

preserve_geometries

Should the edge geometries remain unmodified? Defaults to FALSE. See Details.

Details

If geometries should be preserved, edges are made valid by adding edge boundary points that do not equal their corresponding node geometry as new nodes to the network, and updating the *from* and *to* indices to match this newly added nodes. If FALSE, edges are made valid by modifying their geometries, i.e. edge boundary points that do not equal their corresponding node geometry are replaced by that node geometry.

Value

An object of class sfnetwork with corrected edge geometries.

Note

This function works only if the edge geometries are meant to start at their specified *from* node and end at their specified *to* node. In undirected networks this is not necessarily the case, since edge geometries are allowed to start at their specified *to* node and end at their specified *from* node. Therefore, in undirected networks those edges first have to be reversed before running this function. Use make_edges_follow_indices for this.


luukvdmeer/sfnetworks documentation built on Nov. 21, 2024, 4:54 a.m.