create animation of vehicle moving along a route "with timeline of events"
Asked Answered
K

0

5

This is a followup question on How to create animation of vehicle moving form A to B along a route?. I could learn how to animate vehicles moving from A to B along the route. Thanks for the help!

But is it possible to make a self explanatory video (for a hypothetical client) by adding timeline (with a moving marker showing the instantaneous time and the corresponding event). Example of timeline

For example - Here is a sample sequence of events -

enter image description here

library(sf)
library(dplyr)
library(tidygeocoder)
library(osrm)
library(lubridate)

# adresses
adresses <- c("285 Fulton St, New York, NY 10007", # One World Trade Center
              "11 Madison Ave, New York, NY 10010",
              "Rockefeller Center, 45 Rockefeller Plaza, New York, NY 10111")

# geocoded addresses
geocoded_addresses <- tidygeocoder::geo(adresses, method = "osm") %>%
  st_as_sf(coords = c("long", "lat"), crs = 4326)

# reference time
t <- as_datetime("2021-08-23 8:00:00", tz = "America/New_York")

timeline <- tibble(
  time = c(t, t+minutes(10), t+minutes(12), NA, t+minutes(25), t+minutes(30), t+minutes(32), NA, t+minutes(38), NA),
  events = c("Wait", "Ride request", "Start trip", "End trip", "Ride request", "Start trip", "Ride request", "End trip", "Start trip", "End trip")
)

Knowing answered 24/8, 2021 at 14:16 Comment(5)
I don't have the time right now to prepare an answer, but it should be in principle possible to show the current "stage" of the journey in a ggplot2 / gganimate title. Consider the title in this answer on RStudio forum: community.rstudio.com/t/…Mask
Would you prefer a tmap, gganimate, or mapdeck for the animation?Condensate
I would prefer tmap. I can create the full animation on my own in tmap now . The most important thing is add a timeline belo the plot (with a moving cursor pointing time and the current event). The idea is to create a self explanatory gif or mp4.Knowing
Are you expecting movement "as the crow flies" or along actual streets?Converted
Along the route you can refer to #68900333. I want to create a timline of events so that the video is self explanatory.Knowing

© 2022 - 2024 — McMap. All rights reserved.