t_distance {psyosphere}R Documentation

Add distance to next coordinate

Description

Distance towards the next coordinate in the tracks.

Usage

t_distance(
  tracks, bind = TRUE, drop = TRUE, cname = "distances_in_m", t_id = "id"
)

Arguments

tracks

psyo. Data frame with 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.

t_id

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

Details

For the last coordinate within a track the function returns empty because there is no distance towards a following coordinate possible. Using 0 instead of NA may be an unwanted bias within the data.

Value

psyo

Note

The distance between the first and the second point is stored with the second point. This is done for higher compatibility with the gap functions.

Author(s)

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

See Also

distHaversine, t_bearing, t_speed, t_time_difference

Examples

data(psyo)
psyo <- psyosphere::t_distance(psyo)

[Package psyosphere version 0.1 Index]