Skip to contents

Convert a vector of 2D coordinate indices into a path data.frame. If ind is a matrix, each row represents the path of a different trajectory j.

This function is the main way to create path in GeoPressureR, and is used by graph_most_likely, graph_simulation and tag2path.

Usage

ind2path(ind, tag_graph, use_known = TRUE)

Arguments

ind

vector of indices of the 2D map (vector or matrix)

tag_graph

either a tag or a graph object, must contains stap, extent and scale.

use_known

If true, enforce the known position in the path created. The known positions are approximated to the map resolution in order to corresponds to integer index.

Value

A path data.frame

  • stap_id stationary period identification

  • j identification for each trajectory (1 to $nj$).

  • lat Latitude,

  • lon longitude

  • ... other columns from stap

See also

Other path: path2edge(), path2elevation(), plot_path()

Examples

setwd(system.file("extdata", package = "GeoPressureR"))
tag <- tag_create("18LX", quiet = TRUE) |>
  tag_label(quiet = TRUE) |>
  tag_set_map(c(-16, 23, 0, 50), scale = 1)

# ind generated by `graph_most_likely` (single trajectory - vector)
ind <- c(1652, 1603, 1755, 1708, 1607)
path <- ind2path(ind, tag)
knitr::kable(path)
#> 
#> 
#> | stap_id|  j|  ind|  lat|  lon|start               |end                 |include |known |
#> |-------:|--:|----:|----:|----:|:-------------------|:-------------------|:-------|:-----|
#> |       1|  1| 1652| 48.5| 17.5|2017-07-26 23:57:30 |2017-08-04 19:47:30 |TRUE    |FALSE |
#> |       2|  1| 1603| 47.5| 16.5|2017-08-04 23:17:30 |2017-08-05 19:27:30 |TRUE    |FALSE |
#> |       3|  1| 1755| 45.5| 19.5|2017-08-06 02:52:30 |2017-08-06 19:12:30 |TRUE    |FALSE |
#> |       4|  1| 1708| 42.5| 18.5|2017-08-07 03:12:30 |2017-08-07 19:12:30 |TRUE    |FALSE |
#> |       5|  1| 1607| 43.5| 16.5|2017-08-08 00:12:30 |2017-08-09 23:57:30 |TRUE    |FALSE |

# ind generated by `graph_simulation` (10 trajectories - matrix)
ind <- matrix(c(
  1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652,
  1653, 1606, 1653, 1504, 1604, 1704, 1504, 1653, 1753, 1701,
  1805, 1457, 1408, 1657, 1609, 1903, 1506, 1757, 1856, 1804,
  1607, 1514, 1611, 1457, 1860, 1802, 1759, 1609, 1760, 1208,
  1505, 1314, 1559, 1357, 1758, 1852, 1661, 1706, 1862, 1358
), nrow = 10)
path <- ind2path(ind, tag)
knitr::kable(head(path, n = 15))
#> 
#> 
#> | stap_id|  j|  ind|  lat|  lon|start               |end                 |include |known |
#> |-------:|--:|----:|----:|----:|:-------------------|:-------------------|:-------|:-----|
#> |       1|  1| 1652| 48.5| 17.5|2017-07-26 23:57:30 |2017-08-04 19:47:30 |TRUE    |FALSE |
#> |       1|  2| 1652| 48.5| 17.5|2017-07-26 23:57:30 |2017-08-04 19:47:30 |TRUE    |FALSE |
#> |       1|  3| 1652| 48.5| 17.5|2017-07-26 23:57:30 |2017-08-04 19:47:30 |TRUE    |FALSE |
#> |       1|  4| 1652| 48.5| 17.5|2017-07-26 23:57:30 |2017-08-04 19:47:30 |TRUE    |FALSE |
#> |       1|  5| 1652| 48.5| 17.5|2017-07-26 23:57:30 |2017-08-04 19:47:30 |TRUE    |FALSE |
#> |       1|  6| 1652| 48.5| 17.5|2017-07-26 23:57:30 |2017-08-04 19:47:30 |TRUE    |FALSE |
#> |       1|  7| 1652| 48.5| 17.5|2017-07-26 23:57:30 |2017-08-04 19:47:30 |TRUE    |FALSE |
#> |       1|  8| 1652| 48.5| 17.5|2017-07-26 23:57:30 |2017-08-04 19:47:30 |TRUE    |FALSE |
#> |       1|  9| 1652| 48.5| 17.5|2017-07-26 23:57:30 |2017-08-04 19:47:30 |TRUE    |FALSE |
#> |       1| 10| 1652| 48.5| 17.5|2017-07-26 23:57:30 |2017-08-04 19:47:30 |TRUE    |FALSE |
#> |       2|  1| 1653| 47.5| 17.5|2017-08-04 23:17:30 |2017-08-05 19:27:30 |TRUE    |FALSE |
#> |       2|  2| 1606| 44.5| 16.5|2017-08-04 23:17:30 |2017-08-05 19:27:30 |TRUE    |FALSE |
#> |       2|  3| 1653| 47.5| 17.5|2017-08-04 23:17:30 |2017-08-05 19:27:30 |TRUE    |FALSE |
#> |       2|  4| 1504| 46.5| 14.5|2017-08-04 23:17:30 |2017-08-05 19:27:30 |TRUE    |FALSE |
#> |       2|  5| 1604| 46.5| 16.5|2017-08-04 23:17:30 |2017-08-05 19:27:30 |TRUE    |FALSE |