join_points_lines: A function to identify the nearest coordinate in a line for a...

View source: R/join_points_lines.R

join_points_linesR Documentation

A function to identify the nearest coordinate in a line for a point, using sf objects.

Description

This function allows you to get the coordinates for the closests point in a line for an input point. This function uses the snapPointsToLines from the sp package but accept sf as inputs. The process must be made in geographic coordinates, so if the sf inputs are in lon/lat coordinates, they must be tranformed. If no crs is specified as projected, the default crs is 3116. A crs for the output can also be choosen, by default, the result will be in crs 4326 (WGS84)

Usage

join_points_lines(points, lines, crs_projected = NULL, crs_out = NULL)

Arguments

points

The sf object containing points

lines

The sf object containing lines

crs_projected

The crs which will be used to find the neares points and calculete euclidean distances

crs_out

The crs used for the coordinates at the final dataframe

Value

A dataframe containing the origin id, coordinates, and the destination coordinates as lon_dest and lat_dest

Examples

destino_bici <- join_points_lines(direcciones, ciclorruta) %>%
select(id, lon_dest, lat_dest)

samesag/emu documentation built on Aug. 22, 2023, 3:19 p.m.