Learn R Programming

traipse (version 0.3.0)

track_distance: Track distance

Description

Calculate geodesic distance on longitude, latitude input vectors. The unit of distance is metres.

Usage

track_distance(x, y)

Value

numeric vector of distances between sequential pairs of x, y in metres, see Details

Arguments

x

longitude

y

latitude

Details

By convention the first value is set to NA missing value, because the distance applies to each sequential pair of locations.

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

Examples

Run this code
track_distance(trips0$x, trips0$y)[1:10]

Run the code above in your browser using DataLab