Making Movies of Trajectories

To render a movie, we render short subsets of trajectories over and over. As such we can re-use all of the arguments and algorithms we already have for rendering trajectory maps with just a few additions for movie duration, frames per second, and trajectory length.

Terrestrial Movie

We’ll begin with a short movie (10 seconds long, 10 frames per second) where each moving object has a trail showing the last hour of its motion:

$ python -m "tracktable.examples.movie_from_points"
     --trail-duration 3600
     --trajectory-linewidth 2
     --fps 10
     --duration 10
     TRACKTABLE/examples/data/SampleTrajectories.csv
     MovieExample1.mp4

This will encode a movie using vanilla MPEG4 that should be playable by anything less than ten years old. Quicktime Player, iTunes, and Windows Media Player can all handle this. If you don’t already have VLC installed we recommend that as well.

We have two more features to demonstrate here. First, instead of having the trajectory lines be of constant width along their length we can have them taper as they get older. We do this with --trajectory-width taper, trajectory-initial-linewidth and trajectory-final-linewidth. We will also put a dot at the head of each trajectory with --decorate-trajectory-head and trajectory-head-dot-size.

$ python -m "tracktable.examples.movie_from_points"
   --trail-duration 3600
   --trajectory-linewidth taper
   --trajectory-initial-linewidth 3
   --trajectory-final-linewidth 0
   --decorate-trajectory-head
   --trajectory-head-dot-size 3
   --fps 10
   --duration 10
   TRACKTABLE/examples/data/SampleTrajectories.csv MovieExample2.mp4

Cartesian Movie

As with geographic data, we can also make movies from data in flat Cartesian space:

$ python -m "tracktable.examples.movie_from_points"

  --domain cartesian2d
  --object-id-column 0
  --timestamp-column 1
  --x-column 2
  --y-column 3
  --delimiter ,
  --map-bbox -100 100 -100 100
  --trajectory-linewidth taper
  --trajectory-initial-linewidth 4
  --trajectory-final-linewidth 1
  TRACKTABLE/examples/data/SamplePointsCartesian.csv
  MovieExample3.mp4

NOTE: The trails won’t appear in the movie until several seconds in. This is not a bug. Recall that trails are colored by their progress from start to finish and the default colormap (“heat”) is black at the beginning. If you would like to see them bright and vivid right from the start, add an argument like --trajectory-colormap prism (or any other Matplotib colormap you like).