Skip to contents

Find the position of the highest value in a map, typically most probable value in a likelihood map.

Note that this path is the most likely, considering only the observation model and ignoring the movement model. Prefer to use graph_most_likely() for the most realistic path accounting for flight duration.

interp can be used to interpolate unrealistic position from short stationary periods based on the position of the longer ones. In order to preserve a reference to the grid, the interpolation is only performed at the centre of the grid cell (defined by the likelihood map). Note also that it is not possible to interpolate the first and last stationary period.

Usage

tag2path(tag, likelihood = NULL, interp = FALSE, use_known = TRUE)

Arguments

tag

a GeoPressureR tag object.

likelihood

Field of the tag list containing the likelihood map (character). By default, uses the product of map_pressure and map_light if available, otherwise the first available likelihood map in the tag.

interp

the position of the stationary period shorter than interp will be replaced by a linear average from other position accounting for flight duration (in days).

use_known

If TRUE, enforce known positions from tag$stap when building the path. The exact known_lat and known_lon are used for lat and lon, while ind remains the grid cell index.

Value

A path data.frame

  • stap_id stationary period

  • j identification of the trajectory (always 1).

  • ind indices of the coordinate in the 2D grid. Useful to retrieve map or graph information.

  • lat Latitude,

  • lon longitude

  • ... other columns from stap

  • interp logical indicating if the position was interpolated (see interp).

Examples

# Load a tag with pressure and light likelihood maps computed with `geopressuretemplate()`
withr::with_dir(system.file("extdata", package = "GeoPressureR"), {
  tag <- load_interim("18LX", var = "tag")
})

# Extract a path from pressure map
path <- tag2path(tag)
plot_path(path)
# Short stationary periods (e.g. 1 day) can be unreliably # estimated, so interpolating them is often better path <- tag2path(tag, interp = 1) plot_path(path)