nearest_ids | R Documentation |
Extract the indices of nearest nodes or edges to given spatial features
nearest_node_ids(x, y, focused = TRUE)
nearest_edge_ids(x, y, focused = TRUE)
x |
An object of class |
y |
Spatial features as object of class |
focused |
Should only the indices of features that are in focus be
extracted? Defaults to |
To determine the nearest node or edge to each feature in y
the function st_nearest_feature
is used. When extracting
nearest edges, spatially explicit edges are required, i.e. the edges table
should have a geometry column.
An integer vector with each element containing the index of the
nearest node or edge to the corresponding spatial features in y
.
library(sf, quietly = TRUE)
net = as_sfnetwork(roxel)
pts = st_sample(st_bbox(roxel), 6)
nearest_node_ids(net, pts)
nearest_edge_ids(net, pts)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.