distance_to_direct_line {psyosphere}R Documentation

Add deviation from shortest route from begin of track to a line

Description

Add deviation from shortest route from begin of track to a line

Usage

distance_to_direct_line(
  tracks, line, bind = TRUE, drop = TRUE, cname = "distance_to_direct_line",
  t_id = "id"
)

Arguments

tracks

psyo. Data frame with tracks.

line

list. A list with the column lon (numeric) and lat (numeric).

t_id

character or numeric. Column name in tracks that identifies the separate tracks.

bind

logical. Return the distance as list (FALSE) or add it to tracks (TRUE).

drop

logical. If TRUE and only one observation is returned drop the data frame and collapse the return value to a vector.

cname

character. Column name of the returned calculation result.

Value

psyo. Distance in meter.

Credit

If you use Psyosphere for commercial use or research, please support us by include one off the following references:

Author(s)

Benjamin Ziepert. Please send feedback to: feedback-psyosphere@analyse-gps.com.

See Also

distance_line

Examples

# Get data
data(psyo_rounds2)
data(psyo_rounds_map)

# Create finish line
finish <- data.frame(lon = c(6.851810,6.851000), lat = c(52.241800,52.240300))

# Plot tracks and finish
plot <- psyosphere::plot_tracks(psyo_rounds2, t_id = "", plot = psyo_rounds_map)
# plot <- psyosphere::plot_tracks(psyo_rounds2, t_id = "")
psyosphere::plot_line(finish, plot = plot)

# Get deviation from shortest rout from begin to finish
psyo_rounds2 <- psyosphere::distance_to_direct_line(psyo_rounds2, finish)

[Package psyosphere version 0.1 Index]