interpolateTrack: Track Interpolation

View source: R/RWalc.R

interpolateTrackR Documentation

Track Interpolation

Description

Interpolate a track to a given set of time points by one of several methods.

Usage

interpolateTrack(
  data,
  predict = NULL,
  method = c("approx", "loess", "gc", "mean"),
  loess.span = 0.1
)

Arguments

data

A dataframe representing the track (see details).

predict

A vector of times (POSIXct) or a dataframe of segments and times for which to predict locations.

method

Method used to interpolate the track.

loess.span

Span used in the loess smooth.

Details

The track may consist of several independent segments. These segments may represent either distinct segments of a single track, or distinct tracks that may overlap in time.

The input track must is given as a dataframe where each row is an observed location, with columns:

- 'segment': integer label for the segment (optional) - 'date': observation time (GMT POSIXct) - 'x': observed x coordinate - 'y': observed y coordinate - 'x.se': standard error of the x coordinate (optional) - 'y.se': standard error of the y coordinate (optional)

It is assumed the input dataframe is ordered by segment and by date within segment.

The 'predict' argument specifies prediction times for which locations along the track will be predicted. When the track consists of a single segment, these argument may be a vector of POSIXct times, otherwise it must be a dataframe with columns:

- 'segment': track segment (integer, optional) - 'date': prediction time (as GMT POSIXct)

The fitted track is returned as a dataframe containing both the original and predicted locations. To obtain just the predicted locations, the dataframe should be subset by the 'predicted' column.

Several interpolation/smoothing methods are available:

- '"approx"': linear interpolation in x and y - '"loess"': loess smoothing in x and y - '"gc"': Assumes x is longitude and y is latitude and interpolates along a great circle - '"mean"': the track is replaced by its weighted centroid

Value

Returns a dataframe with columns: - 'segment': track segment - 'date': time (as GMT POSIXct) - 'observed': whether this was an observed time - 'predicted': whether this was a predicted time - 'x': x coordinate - 'y': y coordinate


SWotherspoon/RWalc documentation built on June 10, 2025, 6:46 a.m.