If we want driving directions from Google Maps, one easy way to generate GPS data points in a .GPX file is to:
- use google maps to generate a route
- grab the URL generated above in Google Maps and feed it to GPS Visualizer to get a .gpx file with the GPS data points following the given route
If, instead, we want GPS points from a route that we did previously, we can just, for example, download the GPX file directly from Endomondo.
At these point, we can try our luck with sites like http://gpxhyperlapse.com/ or http://alban.atchoum.fr/hyperlapse/ but if we want finer control, we will need to do some extra work.
If we use the .gpx files above, the results will not be very good, since there will be not many data points and/or due to the GPS receiver limitations, the points can be outside roads, resulting in shaky and jumpy street view images. So, we can do two things to improve this.
First, we are going to generate more data points by interpolating, with GPSbabel (see http://www.gpsbabel.org/htmldoc-development/filter_interpolate.html) For example, to get data points every 5 meters:
gpsbael -i gpx -f track.gpx -x interpolate,distance=0.005k -o gpx -F newtrack.gpx
Second, we can try to fit those GPS points to a proper road (assuming we were on a bike tour, running, etc. on roads). To do this, we can use the site https://mapmatching.3scale.net/. You need to apply for an API key. Once you do that, we can convert our original shaky GPS data with
curl -X POST -H 'Content-Type: application/gpx+xml' --data-binary @newtrack.gpx "http://test.roadmatching.com/rest/mapmatch/?app_id=YOUR_APP_ID&app_key=YOUR_APP_KEY&output.waypoints=true" -o output.xml
This works OK with the GPX file from Endomondo, which has time stamps, but it will break (the developer knows about this, so perhaps it is fixed when you try it) for the Google Maps generated GPX file, which doesn't have time stamps. To fix it, we just have to add timestamps to the GPX file before accessing test.roadmatching.com. So I turn all the trkpt from something like:
to something like (you can just put the same timestamp for all the trkpt's):
The output from TrackMatching matches the roads much better, hopefully, than the original GPX data, but it comes in an unfamiliar format that I have not been able to convert easily to a GPX file (if you know how to do it with some GPS conversion software, please let me know). I was too lazy to write a script to do the necessary transformations automatically, and instead I used search/replace in my text editor, so that from the output.xml file I extract all the wpt ....="" stuff and modify each waypoint of the form wpt y="28.465961" x="-16.269638" to (if you don't know how to do search/replace with regular expressions, this is a good time to learn!):
Now in the .gpx file obtained with GPSBabel, delete all the trkpt entries (so there will be an empty
With the help of GPS Visualizer again, you can
git clone https://gist.github.com/cac3a4434c4bd5b756ea.git
The file gpxhyper.py is still very crude, so you will have to change things by hand. It will work by default on a file called input.gpx (either change that or make a symbolic link named input.gpx pointing to the file you want to work with). Next, leave uncommented the appropriate line: for the .gpx file coming from Endomondo:
gpx_trackseg = gpx_file.getroot()[1][3] # For Endomondo .gpx
For the .gpx file coming from Google Maps:
gpx_trackseg = gpx_file.getroot()[3][1] # For GPSBABEL .gpx
You should also have a Google Street View Image API Key (if you don't have one, you can get instructions at https://developers.google.com/maps/documentation/streetview/#api_key). Put it in gpxhyper.py (in place of YOUR_GOOGLE_API_KEY) and execute it as:
python gpxhyper.py
and all the corresponding images will be downloaded from Google Street View.
From these images use your favourite method to create a video. For example:
avconv -r 10 -i %5d.jpeg -b:v 1000k input.mp4
As an example, here it is the result for an Endomondo generated track (a bicycle route):