nn_point: Fast search for the nearest point to another set of points

Description Usage Arguments Details Value See Also Examples

View source: R/osm_cleaning_functions.R

Description

Fast search for the nearest point to another set of points

Usage

1
nn_point(x, y, clusters = NULL)

Arguments

x

a SF data frame of POINTS

y

a SF data frame of POINTS

clusters

a list of integers, default NULL

Details

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

Value

Returns an list of ids and distances

See Also

Other OSM: cluster_junction(), line_segment_sf(), nn_line(), osm_consolidate(), osm_get_junctions(), osm_main_roads()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
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)

## End(Not run)

saferactive/traffiCalmr documentation built on Nov. 18, 2021, 5:06 a.m.