Tuesday, April 1, 2014

3D GPS Visualization Workflow of Snowboarding Sessions



I recently got crazy into snowboarding and thought it would be neat to play around with some data visualization methods.  Here's exactly how I created the video above of a session at Spirit Mountain on March 30, 2014.

Tools:

  • Android phone (any mobile device with a GPS receiver that can provide GPX exports [or any other GPS output format] will work)
  • AlpineReplay app (any GPS tracking app or sports tracking app will do)
  • Google Earth
  • MS Paint / Google Picasa / Gimp / Photoshop / your favorite graphics processing software
  • Camtasia (or CamStudio) screen capture software
  • Sony Vegas (any NLE / video editing software will do, but more powerful software provides cooler features)

Data Collection:

  1. Load AlpineReplay onto your device and hit the big play button
  2. Get rad
  3. Press pause at the end of your sesh, and hit Send
Now just grab the GPX export of this session from the AlpineReplay web site (using a desktop computer):
  • Log in to AlpineReplay.com
  • From the navigation menu at the top, choose Account > Settings
  • Scroll to the very bottom of the page. Under Data Export, click the Export Data to GPX link
  • Select you session by date & time from the drop-down menu, and click the Download button to get a single GPX file for an individual session composed of multiple slope and lift rides
Simple!

Render in 3D:

  • Install and open Google Earth
  • Choose File > Open and navigate to the directory where you downloaded the GPX file.  It's probably sitting in D:\Users\[user name]\Downloads
  • Change the expected file format to GPS so Google Earth will show any GPX files (etc.) you have on your machine. Click the drop-down menu over the Open and Cancel buttons and choose
    GPS (*.gpx, *.loc, *.mps, *.gdb...)
  • Click OK on the GPS Data Import dialog to continue with default settings. Make sure Adjust altitudes to ground height is selected so it conforms better to the DEM (Digital Elevation Model)

Now you can zoom, pan, tilt, and go to town playing with your data.  

Create a snapshot image:

At this point it already looks pretty sweet so I took a screenshot (using the Print Screen button on my keyboard) and ran it through through Gimp to crop, tune, and add a few filters. Maybe I went overboard, but it looks cool.


Google Earth Recommended Settings:

By default, Google Earth may put some extra crap on the map that you don't want.  Maybe you want to add roads or other information. That's cool, but I don't want it now.
  • In the bottom left corner of Google Earth, expand the Layers menu
  • Click to clear/un-check the box next to Primary Database so we can re-add one layer at a time
  • I am really only interested in that awesome Lidar data that Google incorporates into its DEM, so put a check next to 3D Buildings. If you expand that layer, make sure at least the Photorealistic layer is checked


Turn off some map clutter:
  • From the View menu at the top of the Google Earth window, un-select Tour Guide, and Status Bar
    (Although the status bar can be very helpful, so don't forget how to turn that back on later)
If you have a decent processor and graphics card, consider boosting your rendering with these settings:
  • Click Tools > Options to open the Google Earth Options dialog. The following settings are all under the 3D View tab, but get familiar with the rest of the settings in here if you want to work with Google Earth some more
  • Set Anisotropic Filtering to High
  • Check Use high quality terrain
  • Check Use photorealistic atmosphere rendering (EXPERIMENTAL)

Symbology:

  • Expand the Places menu on the left side of the program to view the layers you have loaded in your map display
  • By default, your imported GPX file will load into the Temporary Places category and should be labeled as GPS Device. Drag that into My Places, and un-check Sightseeing Tour.  Now if you close Google Earth, this GPS track will load by default

The thick blue line isn't dong it for me. Let's make the track look a bit better.
  • Right click on your GPS device layer (if you haven't already renamed it) and chose Properties
  • Navigate to the Style, Color tab
  • Most importantly, change the Width to something around 2.0 to 3.0.  A thin bright line is important in this method
  • I prefer a 100% Opacity for the next animation trick too
  • I usually avoid red on maps, but I really want it to stand out and I don't have a red-green color impairment, so I'll change mine to full on Red. Those with a red-green color impairment may have a difficult time seeing the contrast between green trees and the red track, but I digress

Right: Simulated red-green color impairment (deuteranopia)
Left: Normal rendering

Animation:

Hover over the Time Slider toolbar to interact with its controls. It appears when GPS layers (or any other layer with time attribute data) are added to the scene.
! Read more about the Time Slider from Google's documentation

  • Click on the wrench icon in the upper left corner to open the Time Options dialog
  • Move the Animation speed slider somewhere toward the middle to slow down the animation. Return here and tune it to your liking later
  • Check the Loop animation option and click OK

We'll need to define a time range for the little trail effect. Note on the screenshot below that there are two controls on the timeline. The control on the far right points to the current location in the time sequence - it's essentially track position, just like you would see on YouTube, or another media player. The control on the far left is the range marker. The further away it is from the time position marker, the longer your trails will be.


  • Click and drag the time position marker (the control on the right) somewhere into the middle of the time bar. Something funny happens if it's not moved from the far right.  Anywhere besides at the very end/beginning position will do
  • Click and drag the range marker (the funny icon on the left) closer to the time position marker
  • Play around with it until the track's tail looks sufficiently long
The tail on the left is probably too long for this type of visualization.
The tail on the right looks too short to be useful.
(Note: I didn't move the time marker away from
the end for these screenshots)

The length of this tail looks about right.
  • Run the animation! Click the fourth icon from the top left to start the animation. It looks like a white clock with a "play" button/arrow on the right
  • Review the tail length. Click that same icon to pause the animation and adjust the range marker to shorten/lengthen the tail
  • Click the wrench icon again to adjust the speed of the animation

Screen Capture:

This was a real pain, and I'll explain why as we move along.

First, we want a high quality output in a format that we can edit later. Right off the bat, anything that can only export .swf is out because we have to jump through extra hoops to get it to work with video editing software.
! Usually CamStudio will do the trick, but I'm having trouble finding an legitimate h.264 encoder (.mp4 file type, high quality, high quality compression, manageable output file size) or other codecs that isn't straight spyware. All I'm getting for outputs are 2-5 frames per second that look like garbage.
I settled on Camtasia Recorder which produces very good quality, high frame rate .avi files. The drawback is that it's not free like CamStudio is.

Although Google Earth looks pretty impressive on its own AND the time lapse location animation looks really cool too, it would be nice to illustrate the the 3D aspect a little more directly.  Slight movement in a 3D scene really shows off dynamic depth in a 3D scene, however Google Earth doesn't do a very good job of letting the user control subtle movement.  It does a great job of moving significant distances (say between various locations across town, or across the globe) but it was very tricky to get the program to keep the camera fixed on one spot while rotating about that location. Here's what I did instead for the video
  • Turn on the looping GPS animation in the time slider
  • Compose a shot from a low angle (close to the ground ) to show the dramatic topography along with some sky along the horizon in the background. I even tried to align the shot so that the GPS path would briefly hide behind some 3D trees in a few areas to really highlight that third dimension
  • Let the animation run a few times to find and adjust the best viewing angles
  • Configure and engage screen recording software
  • While Camtasia was recording, I placed the cursor out of the recording area and subtly and slowly dragged the scene back and forth in a "smooth" manor
The subtle movement would have been better with a rotating motion (clicking and dragging with the mouse wheel button [or Shift + Left/Right], rather than dragging with the left mouse button), but the controls moved way too quickly and the shot would have been jerky and awkward.

The drawbacks were that this is still pretty jerky movement as I didn't have a ton of control with the mouse and a human hand at slow speeds, so I countered it with a movement effect in Sony Vegas. I added a slow and subtle zoom in and pan effect via three keyframes.  One at the beginning, one in the middle, and a copy of the first keyframe that was pasted at the end so the motion would end where it originated.  This part was all hands-off so it was far smoother than a human hand could ever produce.

That's it!  Here's the video again:

Unfinished Ideas:

  • Snow is a pretty important factor in a snowboarding. Google acquired mostly leaf-on imagery. Here's an idea to change that - at least a little:
Here's my first attempt at adding snow to a Google Earth scene
    • Obtain imagery. If you can find winter imagery, you're done. Otherwise, download spring/summer orthophotography; even grabbing a screenshot from Google maps will work
    • Use Gimp/Photoshop/etc. to turn the photo into snow.  Here's a brief workflow I used:
      • Turn down the saturation all the way so the color photo turns black & white
      • Invert the colors so the areas of mid-dark trees become more white instead of more black
      • Boost the contrast so those mid-tones become brighter white
      • Play with the brightness to fine tune your new winter scene
    • Export that image and add it to Google Earth as a new image overlay (Add > Image Overlay or use the Ctrl + Shift + O shortcut command)
      • After you align/georeference the overlay, adjust the transparancy slightly to help it blend into the scene to your liking
    Unfortunately this image doesn't snap to the "3D Buildings" layer with the high resolution Lidar DEM, but that might be okay. It looks kind of cool to have the trees sticking out, but that's up to your discretion.

    The other alternative is to just turn off the 3D buildings to have a completely snow-covered landscape.  This option will require high resolution imagery to pull off when zoomed in, however.

  • Change the location icon from an arrow to a snowboarder/skier
    • In the Places menu, expand your GPS track layer until you see the symbol for the arrow
    • Right click this layer and choose Properties
    • Cilck the button at the top right corner of the Edit Track dialog to change the icon used for this symbol.  

      I chose the skier icon, but you can add a custom in this dialog box if you create your own snowboarder dude.  I'd suggest rotating it 90° anti-clockwise so it looks like it's snowboarding in the direction of travel. The skier dude looks kinda funny in certain directions.

  • I'd like to combine this with some footage from my cameras.  I have a GoPro camera, and some other HD Canon cameras that have waterproof housings which are ideal for shooting in snow and cold weather
  • A clock face rushing through time would be pretty neat instead of text time stamps rushing by. It would be a more intuitive way to gage how fast real time is passing
  • Using the GPS data as information overlays would be sick!  I'm thinking some way to illustrate gauges (instruments) that report things like:
    • Speed 
    • Altitude/elevation
    • G-forces (from phone accelerometers, not necessarily from a GPS signal, but this could  theoretically be calculated to a degree from the raw data)
    • Change in speed (acceleration/deceleration)