R/osm_cleaning_functions.R
nn_point.Rd
Fast search for the nearest point to another set of points
nn_point(x, y, clusters = NULL)
x | a SF data frame of POINTS |
---|---|
y | a SF data frame of POINTS |
clusters | a list of integers, default NULL |
Returns an list of ids and distances
If clusters
is null will find the nearest y point for each x point
and return a list of two vectors indexes of y length(x) and a distances
length(x). If clusters
is a list e.g. from cluster_junction
then the
indexes are replaced with the matching indexes of clusters
Other OSM:
cluster_junction()
,
line_segment_sf()
,
nn_line()
,
osm_consolidate()
,
osm_get_junctions()
,
osm_main_roads()
if (FALSE) { junctions = osm_get_junctions(osm) junction_clusters = cluster_junction(junctions) # Find the nearest junction near_junction = nn_point(crash_junction, junctions) # Find the nearest junction cluster near_cluster = nn_point(crash_junction, junctions, clusters = junction_clusters$junction_ids) }