nn_line: Fast search for the nearest lines to a set of points

Description Usage Arguments Details Value See Also Examples

View source: R/osm_cleaning_functions.R

Description

Fast search for the nearest lines to a set of points

Usage

1
nn_line(point, lines, k = 50, ncores = 1)

Arguments

point

a SF data frame of POINTS with projected CRS

lines

a SF data frame of lines with projected CRS

k

integer how many lines to search

ncores

integer how many cores to use in parallel processing, default = 1

Details

The nearest line to a point is a non-trivial calculation which in theory requires checking the distance to every possible line. This function takes a shortcut by measuring distances to the centroids of lines, and then cross checking only nearby lines. The number of lines checked is defined by k. This process cannot guarantee 100% accuracy by is many orders of magnitude faster. To increase accuracy increase k.

Value

Returns an list of ids and distances

See Also

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

Examples

1
2
3
4
## Not run: 
crash_road_nn = nn_line(crash_road, osm, ncores = 5)

## End(Not run)

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