Skip to contents

Calculates the distance between the consecutive locations of a Move or MoveStack object.

Usage

# S4 method for class '.MoveTrackSingle,missing'
distance(x)
  # S4 method for class '.MoveTrackStack,missing'
distance(x)

Arguments

x

a move, moveStack or moveBurst object

Details

pointDistance is used to calculate the distances.

Value

Distance in map units.
If the projection of the coordinates is long/lat all values are returned in meters, otherwise in the map units of the projection of the move object. For long/lat distance is calculated on a sphere using the ellipsoid, for other projections the calculation is done on a plane using Pythagoras. Check and set the projection of your Move, MoveStack or MoveBurst object using the proj4string() function.

If a move or moveBurst object is provided, a numeric vector one element shorter than the number of locations is obtained.
If a moveStack object is provided, a list with one element per individual containing a numeric vector one element shorter than the number of locations is obtained

Author

Marco Smolla & Anne Scharf

Examples

## distance from a Move object 
data(leroy)
head(distance(leroy))
#> [1]  6.382461  5.606722 12.671263  9.651801 11.733921 13.928818
# to add this information to the move object, a "NA" has to be assigened
# e.g. distance is assigned to the first location of a segment
leroy$distance <- c(distance(leroy), NA)

## distance from a MoveStack object
data(fishers)
str(distance(fishers))
#> List of 2
#>  $ Leroy  : num [1:918] 6.38 5.61 12.67 9.65 11.73 ...
#>  $ Ricky.T: num [1:999] 153.35 12.62 7.81 10.23 13.18 ...
# to add this information to the moveStack object, a "NA" has to be assigened
# e.g. distance is assigned to the first location of a segment
fishers$distance <- unlist(lapply(distance(fishers), c, NA))