#' Searches a movement trajectory dataframe and summarises distance (ignoring y) to a reference position as average or minimum.

extract_movement_dist(
  ref_movement,
  ref_position,
  min_time = min(ref_movement$time, na.rm = TRUE),
  max_time = max(ref_movement$time, na.rm = TRUE),
  method = "min",
  threshold = 0
)

Arguments

ref_movement

A dataframe of movement (must contain standard trajectory columns, i.e. "time", "pos_x", "pos_y", "pos_z").

ref_position

Reference position, stored as a list containing "pos_x", "pos_z" items.

min_time

Minimum time within the ref_movement (taken from "time" column) to search.

max_time

Maximum time within the ref_movement (taken from "time" column) to search.

method

whether to extract "min" (default), "max", "mean", "mse", or proportion of time the distance is "less" or "greater" than a threshold

threshold

numerical threshold if method is "less" or "greater", ignored otherwise

Value

A numeric value of the minimum 2D distance of the ref_movement trajectory to the supplied safe position.

Details

The "mse" option (Mean Squared Error) calculates the time weighted average of squared disance (Squared error) from the reference position.