mt_interpolate {move2}R Documentation

Linearly interpolate locations

Description

Linear interpolation along the straight line between consecutive locations.

Usage

mt_interpolate(x, time, max_time_lag, omit = FALSE)

Arguments

x

A move2 object

time

The times to interpolate to, if missing the interpolation is to the empty locations. Alternatively if the timestamps in x are POSIXct then also an interval can be provided. For details on the interval specification see floor_date.

max_time_lag

The maximal time lag to interpolate over, if not provided any interval is interpolated

omit

If the original location that do not match a value in time should be omitted. This only takes affect when time is not missing.

Details

Each interpolation is done along a straight path from the previous to the next location. Interpolation is done with st_line_sample when there is no CRS provided and s2_interpolate_normalized when the data has a projection.

Value

A move2 object with the interpolated locations

Examples

data <- mt_sim_brownian_motion(t = c(0, 0.6, 3, 3.5))
## interpolating at specific times
mt_interpolate(data, c(.5, 1.5, 2.5))
## interpolating to empty locations
data$geometry[c(1, 3)] <- sf::st_point() ## creating empty locations
mt_interpolate(data)

fishers <- mt_read(mt_example())[1:200, ]
mt_interpolate(fishers, "2 hours")
## omit the original records
mt_interpolate(fishers, "2 hours", omit = TRUE)


[Package move2 version 0.3.0 Index]