track_distance_to: Track distance to location/s

Description Usage Arguments Details Value Examples

View source: R/track_distance_to.R

Description

Calculate geodesic distance to a location or locations based on longitude, latitude (from) input vectors and longitude, latitude (to) input vectors. The unit of distance is metres. The to values may be a single value or individual to each from location.

Usage

1
track_distance_to(x, y, to_x, to_y)

Arguments

x

longitude

y

latitude

to_x

longitude vector of to location/s

to_y

latitude vector of to locations/s

Details

No missing values are required as padding, but input data with NAs will incur an NA in the output.

To use this on multiple track ids, use a grouped data frame with tidyverse code like data %>% group_by(id) %>% mutate(distance = track_distance_to(lon, lat, to_lon, to_lat))

Value

a numeric vector of distance-to values in metres

Examples

1
track_distance_to(trips0$x, trips0$y, to_x = 147, to_y = -42)[1:10]

traipse documentation built on Jan. 13, 2021, 7:11 a.m.