Learn R Programming

spNetwork (version 0.4.4.7)

snapPointsToLines2: Snap points to lines

Description

Snap points to their nearest lines (edited from maptools)

Usage

snapPointsToLines2(points, lines, idField = NA, snap_dist = Inf, ...)

Value

A feature collection of points with the projected geometries

Arguments

points

A feature collection of points

lines

A feature collection of linestrings

idField

The name of the column to use as index for the lines

snap_dist

A distance (float) given to find for each point its nearest line in a spatial index. A too big value will produce unnecessary distance calculations and a too short value will lead to more iterations to find neighbours. The default value is Inf. The function will raise an error if some points are too far from a line.

...

unused

Examples

Run this code
# reading the data
data(mtl_network)
data(bike_accidents)
mtl_network$LineID <- 1:nrow(mtl_network)
# snapping point to lines
snapped_points <- snapPointsToLines2(bike_accidents,
    mtl_network,
    "LineID"
)

Run the code above in your browser using DataLab