Skip to contents

Calculates the fraction of a LineString's length to a point that is closes to a corresponding point in y.

Usage

locate_point_on_line(x, y)

Arguments

x

an object of class rs_LINESTRING

y

an object of class rs_POINT

Value

A numeric vector containing the fraction of of the LineString that would need to be travelled to reach the closest point.

Examples

x <- geom_linestring(c(-1, 0, 0), c(0, 0, 1))
y <- geom_point(-0.5, 0)
locate_point_on_line(x, y)
#> [1] 0.25