Learn R Programming

alcyon (version 0.7.0)

matchPointsToLines: Match points to lines

Description

Match points to their closest line. Matches (spatial-join) points to lines. Finds the point closest to a line. One point is attached to one line, thus if fewer points than lines are given then some lines will have no point attached.

Usage

matchPointsToLines(points, lines, getIndex = FALSE)

Value

If getIndex is TRUE then the index of the points as they relate to the matching lines are given. If not, then the data from the points dataframe is returned.

Arguments

points

Points to attach.

lines

Lines to attach to.

getIndex

Get the index returned and not the data.

Examples

Run this code
segmentsMif <- system.file(
    "extdata", "testdata", "barnsbury",
    "barnsbury_small_segment_original.mif",
    package = "alcyon"
)
segmentsSf <- st_read(
    segmentsMif,
    geometry_column = 1L, quiet = TRUE
)
gateCountsMif <- system.file(
    "extdata", "testdata", "barnsbury",
    "barnsbury_ped_gatecounts.mif",
    package = "alcyon"
)
gateCountsSf <- st_read(
    gateCountsMif,
    geometry_column = 1L, quiet = TRUE
)
matchPointsToLines(gateCountsSf, segmentsSf)

Run the code above in your browser using DataLab