add_nodes_to_graph | R Documentation |
Note that this routine presumes graphs to be dodgr_streetnet
object, with
geographical coordinates.
add_nodes_to_graph(graph, xy, dist_tol = 0.000001, intersections_only = FALSE)
graph |
A |
xy |
coordinates of points to be matched to the vertices, either as
matrix or sf-formatted |
dist_tol |
Only insert new nodes if they are further from existing nodes
than this distance, expressed in units of the distance column of |
intersections_only |
If |
This inserts new nodes by extending lines from each input point to the edge
with the closest point of perpendicular intersection. That edge is then split
at that point of intersection, creating two new edges (or four for directed
edges). If intersections_only = FALSE
(default), then additional edges are
inserted from those intersection points to the input points. If
intersections_only = TRUE
, then nodes are added by splitting graph edges at
points of nearest perpendicular intersection, without adding additional edges
out to the actual input points.
In the former case, the properties of those new edges, such as distance and time weightings, are inherited from the edges which are intersected, and may need to be manually modified after calling this function.
A modified version of graph
, with additional edges formed by
breaking previous edges at nearest perpendicular intersections with the
points, xy
.
Other match:
match_points_to_graph()
,
match_points_to_verts()
,
match_pts_to_graph()
,
match_pts_to_verts()
graph <- weight_streetnet (hampi, wt_profile = "foot")
dim (graph)
verts <- dodgr_vertices (graph)
set.seed (2)
npts <- 10
xy <- data.frame (
x = min (verts$x) + runif (npts) * diff (range (verts$x)),
y = min (verts$y) + runif (npts) * diff (range (verts$y))
)
graph <- add_nodes_to_graph (graph, xy)
dim (graph) # more edges than original
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.