match_points_to_verts {dodgr} | R Documentation |
Alias for match_pts_to_verts
Description
The match_pts_to_graph function matches points to the nearest edge based on geometric intersections; this function only matches to the nearest vertex based on point-to-point distances.
Usage
match_points_to_verts(verts, xy, connected = FALSE)
Arguments
verts |
A |
xy |
coordinates of points to be matched to the vertices, either as
matrix or sf-formatted |
connected |
Should points be matched to the same (largest) connected
component of graph? If |
Value
A vector index into verts
See Also
Other match:
add_nodes_to_graph()
,
match_points_to_graph()
,
match_pts_to_graph()
,
match_pts_to_verts()
Examples
net <- weight_streetnet (hampi, wt_profile = "foot")
verts <- dodgr_vertices (net)
# Then generate some random points to match to graph
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))
)
pts <- match_pts_to_verts (verts, xy)
pts # an index into verts
pts <- verts$id [pts]
pts # names of those vertices