Converts each track into one line
mt_track_lines(x, ...)
A move object
Arguments passed on to the summarise function
A sf::sf object with a LINESTRING
representing the track as geometry for each track. The
track_data
for each track is included as well as the products from summarize
Note that all empty points are removed before summarizing. Arguments passed with ...
thus only summarize for the
non empty locations.
mt_segments()
For transforming all segments to a LINESTRING
separately
mt_sim_brownian_motion() |>
mt_track_lines(
n = dplyr::n(),
minTime = min(time),
maxTime = max(time)
)
#> Simple feature collection with 2 features and 4 fields
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: -2.887059 ymin: -4.388901 xmax: 4.130612 ymax: 0.4523166
#> CRS: NA
#> # A tibble: 2 × 5
#> track n minTime maxTime geometry
#> <int> <int> <int> <int> <LINESTRING>
#> 1 1 10 1 10 (0 0, -0.6491606 0.4135785, -1.470977 -1.476127, …
#> 2 2 10 1 10 (0 0, -1.875135 0.4523166, -2.887059 -0.2889415, …
## empty points are not counted in summary statistic
x <- mt_sim_brownian_motion(1:3)
x$geometry[[2]] <- sf::st_point()
x |> mt_track_lines(
n = dplyr::n()
)
#> In total 1 empty location record is removed before summarizing.
#> Simple feature collection with 2 features and 2 fields
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: 0 ymin: -0.4368751 xmax: 1.528443 ymax: 0.9783934
#> CRS: NA
#> # A tibble: 2 × 3
#> track n geometry
#> <int> <int> <LINESTRING>
#> 1 1 2 (0 0, 0.898042 0.9783934)
#> 2 2 3 (0 0, 0.5152173 -0.4368751, 1.528443 -0.3204166)
## plot of the tracks as a line
mt_sim_brownian_motion(
tracks = letters[1:2],
start_location = list(c(0, 0), c(10, 0))
) |>
mt_track_lines() |>
plot()