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")
)

SiH
  • 1,378
  • 4
  • 18
  • 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: https://community.rstudio.com/t/best-packages-for-making-map-leaflet-vs-ggmap-vs-sf-vs/38403/4?u=jlacko – Jindra Lacko Aug 24 '21 at 15:28
  • Would you prefer a `tmap`, `gganimate`, or `mapdeck` for the animation? – mrhellmann Aug 27 '21 at 01:14
  • 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. – SiH Aug 27 '21 at 04:30
  • Are you expecting movement "as the crow flies" or along actual streets? – Jon Spring Aug 28 '21 at 06:50
  • Along the route you can refer to https://stackoverflow.com/questions/68899833/how-to-create-animation-of-vehicle-moving-form-a-to-b-along-a-route. I want to create a timline of events so that the video is self explanatory. – SiH Aug 28 '21 at 20:32

0 Answers0