track_intermediate: Track intermediate points

Description Usage Arguments Details Value Examples

View source: R/track_intermediate.R

Description

Calculate great circle intermediate points on longitude, latitude input vectors. A spherical model is used, from the geosphere package.

Usage

1
track_intermediate(x, y, date = NULL, distance = NULL, duration = NULL)

Arguments

x

longitude

y

latitude

date

optional input date-time in POSIXct

distance

optional minimum distance (metres) between interpolated points

duration

optional minimum duration (seconds) between interpolated point, if set then distance must be NULL and date must be input

Details

This function returns a list of data frames, with a data frame of interpolated locations for every interval between input locations. There is a final empty data frame to ensure the list is the same length as the inputs. See embedded usage of the tidyr function 'unnest()' for ease of use.

To use on multiple track ids, use a grouped data frame with tidyverse code like inter <- data %>% group_by(id) %>% mutate(inter = track_intermediate(lon, lat, date = , distance = ).

Then, un-nest this result for further use (the 'inter' above retains the information about the parent locations for custom usage if needed), so the final location of each group has invalid intermediates: dd <- inter %>% slice(-1) %>% unnest()

Value

a list of data frames of intermediate points (for use with unnest() from tidyr)

Examples

1
2
3
4
5
6
7
track_intermediate(trips0$x[1:10], trips0$y[1:10], distance = 15000)

track_intermediate(trips0$x[1:10], trips0$y[1:10], date = trips0$date,
                                 distance = 1500)

inter_time <- track_intermediate(trips0$x[1:10], trips0$y[1:10],
                            date = trips0$date, duration = 1800)

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