It was a bright but rainy day at the height of the fall colors, so we took a Sunday drive out to the boonies. I took the camera, but didn’t use it, though the trees were very colorful. Fortunately, I did take the GPS! This video shows the location of our car on a map in relation to the weather as we drove along. If that sounds boring, don’t worry, it has an epic soundtrack thanks to Free Music by DanoSongs.com. Note that the time scale in this video is not constant, as explained in the production notes after the break.
We’d never been to Hermann before, so we stopped at the winery. It’s a very picturesque town, but it was infested with Oktoberfest tourists, and we didn’t stay long. Much later we stopped in Cuba for a fast-food dinner after deciding to try to beat the storms out of Rolla. It was dark by then. There was some spectacular cloud-to-cloud lightning to the north of the highway on the way back to town, before the rains caught us again.
Looks good full screen. I wonder if YouTube does a two-pass reencoding? This looks a lot better now than when I first uploaded it.
Production notes
The GPS logs data in GPX format, which is an XML-based text format that is easy to read. The trip, which took a few hours, resulted in a track log consisting of 3,337 points. Each point is recorded in latitude and longitude in the WGS84 reference system used by the GPS system. So I planned for 3,337 frames, one per track point.
Using QGIS and some shapefiles I already had laying around for the roads, counties, and towns, I created the road map. I gave it an ugly puce background and exported it as a PNG file. Using the Gimp the unique background color was replaced with transparency so the roadmap could ultimately overlay the radar images. QGIS conveniently created an accompanying .pngw worldfile for the map image. Using the data in the worldfile and the image dimensions I determined the geographic coverage of the roadmap. I have a computer archiving the national composite radar-only transparent GIFs from NOAA every 10 minutes, and I have a section of NASA’s Blue Marble image of the earth that matches the scale and location of those radar images. So I was able to determine the crop parameters to extract that part of the radar images and of the Blue Marble background which match the road map’s coverage.
There are only 72 radar images covering the timespan encompassed by 3,337 track points. Each frame of the video includes a composite of the two radar images closest in time to the corresponding track point (the GPS data includes timestamps). The two radar images are blended in proportion to their time distance from the instant of the track point. I first wrote a script to crop the area of each of the 72 radar images that correspond to the area of the road map. Then I wrote a script to scan the GPS data and, using the timestamp embedded in the names of the radar images, create the blended radar images for all 3,337 frames. I set three computers to chew on that while I figured out the details for the next step.
I saved the roadmap image in the same longitude-by-latitude non-projected coordinate reference system used in the raw radar images and the Blue Marble image. So it’s simple 4th-grade arithmetic to find the pixel position on the map image that corresponds to each track point in the GPS data. I created the red ball in Gimp as a PNG with transparency around the ball, and I wrote a script to scan the location data from the GPS data. That emitted another script containing the ImageMagick commands to composite the ball on the road map in the right position for each frame corresponding to those track points. I set multiple computers on that task after they had finished with the radar images.
The final step for creating the animation frames was relatively simple — composite the 3,337 roadmap frames with the red balls over the 3,337 cropped and scaled radar images composited on the Blue Marble background. Feed it all into ffmpeg, and ta-da! the animation is complete.
Unfortunately
The GPS points are not saved on a constant time basis. I have that timing set to “auto” on my unit, so the timing varies, so that you don’t end up with a lot of points piled up when you’re moving slowly or not at all, e.g. The animation uses 29.97 frames per second (before YouTube mangles it), one track point per frame, so the time scale of the animation varies. The weather was moving through fairly steadily, so you can judge the speed of the animation by the speed of the weather. At places where we stopped, such as at Hermann and Cuba, you’ll see the weather suddenly jump when we hit the road again, some span of time having been unrecorded by the GPS.
Believe it or not, I don’t consider this an epic-enough project to re-do it correctly. No, really! If I was to do something like this again, and if I didn’t have the GPS set for constant timing of track points, I would determine what length and frame rate I wanted for the video and derive a sequence of evenly spaced points in time to base the frames on. For each frame I would look at the nearest GPS points in the same manner that I did in this project with the radar images. The result would be an evenly timed video that doesn’t make it look like I’m driving 180 mph on back country roads and dawdling on the interstate.
Music and copyright
I thought of putting car sound-effects to the video and scanned The Freesound Project for likely clips. It soon became clear that that approach would be too much work with too annoying a result. So I started scanning ccMixter for suitable music and found a link to DanoSongs.com where there are many MP3 files available for download and reuse under the very liberal Creative Commons Attribution 3.0 United States License. Thanks, Dan! I found just what I wanted there.
I usually use the slightly more restrictive CC-BY-SA-3.0 license, but decided for simplicity this time to use for the video the same CC-BY license that the audio is distributed under. Yeah, as if anyone is going to want to copy this! I’m pretty sure no one is even reading this far.


