nearestPointOnLine: Get the nearest point on a line to a given point

View source: R/point_line_distance.R

nearestPointOnLineR Documentation

Get the nearest point on a line to a given point

Description

This function calculates the coordinates of the nearest point on a line to a given point. This function does not work with geographic coordinates.

Usage

nearestPointOnLine(coordsLine, coordsPoint)

Arguments

coordsLine

Matrix with coordinates of line vertices. Each row represents a vertex.

coordsPoint

A vector representing the X and Y coordinates of the point.

Value

Vector with the X and Y coordinates of the nearest point on a line to the given point.

Author(s)

German Carrillo

See Also

nearestPointOnSegment, snapPointsToLines

Examples

coordsLine = cbind(c(1,2,3),c(3,2,2))
coordsPoint = c(1.2,1.5)
nearestPointOnLine(coordsLine, coordsPoint)

maptools documentation built on July 26, 2023, 5:38 p.m.