Tag : gpsbabel

Motorrit door de Drôme

Op woensdag 8 augustus 2008 heb ik deze route gereden vanaf Le Camping Moto. Op verzoek van een mede-rijder plaats ik ‘m hier:

En, just for fun, hier nog een kaartje, maar dan een OpenStreetMap met Leaflet.js:


 
Gebruik de map-controls om in/uit te zoomen en de kaart te verschuiven. Bekijk op Google Maps. Download KML.

De benodigde achtergrondinformatie: het KML bestand is met GPSBabel gemaakt van een originele, ongewijzigde GPX track uit een Garmin Zümo. Standaard levert dat een nogal lijvig KML bestand op, omdat GPSBabel ook ‘placemarks’ voor trackpunten genereert. Ten eerste heb je daar niet zoveel aan, en ten tweede wordt het bestand daardoor te groot om in Google Maps te kunnen laten zien. Door de optie ‘points=0’ mee te geven voor de KML output laat je de placemarks weg. De invocatie van GPSBabel wordt dan:

[code]gpsbabel -t -i gpx -f 20120808-track.gpx -o kml,points=0 -F 20120808-track.kml[/code]

Ik heb de track ook geconverteerd naar een route op de manier die ik al eerder beschreef:

[code]gpsbabel -i gpx -o gpx -f 20120808-track.gpx -x transform,rte=trk \
-x nuketypes,waypoints,tracks -x simplify,error=1k -F 20120808-route.gpx[/code]

Met ‘error=1k’ kreeg ik 24 routepunten; met ‘error=0.2k’ kreeg ik er 127. De eerste variant volstaat, en levert op een Garmin Zümo vrijwel helemaal de route op zoals we hem gereden hebben. Het enige verschil zit ‘m in een stukje weg dat de Zümo weigert te gebruiken op de route, waardoor er een rare ‘zijstraat’ in komt te zitten. Dat zal wel een fout in het kaartmateriaal zijn. Download de GPX met de route.

Convert tracks into routes with GPSBabel

Last week, I blogged about creating routes for a Garmin Zümo, using Google Maps and GPSBabel. The main problem that I was trying to solve, is how to create a “real” route that my Zümo will understand, built out of a minimal amount of route waypoints (that show up as such on the Zümo when navigating), rather than possibly thousands of trackpoints, that are hard to process for the device and don’t give you as much navigation flexibility.

This post is about something else, namely how to convert a GPS track (that you created by driving, downloaded somewhere, etc.) into a route, with the same criteria as last time.

Suppose you have a GPX file, containing a track. Typically, such a track contains many trackpoints. For example, a drive of about 60 km that I took a few weeks back, gave me a track consisting of over 2600 trackpoints. Now, I would like to create a route out of this track, that I can share with others.

I don’t know about you, but in my case, a track always contains some stuff that I don’t want to show up in the end result: mistakes that I made during my ride, like entering dead-end streets, or those extra meters that you make, looking for a place to park for a coffee break. Stuff like that is easily corrected with Viking, a nice GPS/track/waypoint editor, that runs on Linux (POSIX) and Windows, and is available under the GPL v2 license. Maybe later I will post something on using Viking, but that’s besides the scope of this post. Let me continue.

So, now I have a GPX, containing the exact track that I want turned into a route. We will use GPSBabel to do the conversion. The invocation is similar to the one in my previous post, but instead of using waypoints, we convert a track into a route, and we add a filter: simplify. I quote:

The Simplify filter is used to simplify routes and tracks for use with formats that limit the number of points they can contain or just to reduce the complexity of a route.

And that is exactly what we need. Simplify will let you specify a maximum number of waypoints in a route, but we will use another feature: maximum error. It allows us (and again, I quote) to specify the maximum allowable error that may be introduced by removing a single point. That means that the nuber of waypoints can be higher on more complex pieces of our route, and lower on the long stretches.

Here we go:

gpsbabel -i gpx -o gpx -f track.gpx -x transform,rte=trk -x nuketypes,waypoints,tracks -x simplify,error=0.1k -F route.gpx

By specifying a maximum error of 0.1k (0.1 km, or 100 m), our original track file, containing a track of 62.84 km in 2641 trackpoints, is converted in to a route file, containing 73 route waypoints.

In the picture, you can see the result. Click to enlarge. In orange is the original track; in green is the resulting route, with dots on the route waypoints. The map is left out for clarity.

I think that this gives us a route, that has enough waypoints not to leave much room for interpretation by the routing engine of a GPS device. My guess is, that most routing engines will calculate identical routes, regardless of your routing parameters, like shortest/quickest route. I haven’t tested this, though.

It speaks for itself, that a higher value for ‘error’ will give you less waypoints, and a lower value will give you more. For example, using ‘error=0.05k’ (50 m), gives me 109 route waypoints. If this is still acceptable, you can profit from the greater accuracy of your route.

Google maps

Now, the funny thing is, that this can also be applied to tracks from Google Maps’ KML files. Please have a look at this post. So if you want to skip the labour-intensive step of creating placemarks for all your route waypoints, you can use the track instead.

The GPSBabel invocation becomes:

gpsbabel -i kml -o gpx -f Routetest.kml -x transform,rte=trk -x nuketypes,waypoints,tracks -x simplify,error=0.5k -F Routetest.gpx

Meaning:

  • Convert KML into GPX
  • Convert the track into a route
  • Remove as many waypoints as possible, creating maximum error of 500 meters
  • Remove tracks and waypoints from the resulting GPX, keeping only the route

With the KML file from my example (a route of some 590 km through some of the best parts of France), this will result in a route, made out of 179 route waypoints, which should be fine for a Garmin Zümo.

Drawback

There is one drawback when using the track from Google as input for a route for -for example- a Garmin device. The waypoints that remain after the conversion are the result of a mathematical algorithm, and their position on the map is absolute. This means, that if there are differences between Google’s map and Garmin’s (and there are!), it can happen, that a route waypoint ends up in an unfortunate location. For example, the waypoint could end up on the other side of the highway, where traffic drives in the opposite direction.

Since the remaining waypoints will be concentrated around crossroads and curves, it is in fact quite likely that at least a few of these problems will occur.

The route on the Garmin might end up with strange loops as a result. Therefore, it is pretty essential to check the final result, either in MapSource or on your GPS device, to prevent unpleasant surprises.

Garmin Zümo, Google Maps, GPSBabel

Tonight, I was looking for the best way to create a route in Google Maps and import it on my Garmin Zümo. I have found an easy way, which does not give the best results, and a way that’s a little more difficult, but will get you more or less exactly what you want. If you want to do this, you need GPSBabel.

First, you need to understand that a Garmin Zümo, and probably other Garmin devices, have a concept called “route waypoints”, which are not waypoints in the regular sense (“favorites” in Zümo-speak), but are the waypoints that a route is made up of.

The objective is, to get a route that is a “real” route in Garmin sense, meaning that it is composed of no more waypoints than necessary, all of which appear on the route as “route waypoints” (orange flags on a Zümo). This is good, because the device will always navigate to the next route waypoint, which is convenient when you have to recalculate the route underway.

The easiest way is to just create your route in Google Maps (you know, draw a line that sticks to roads and drag it around to make it suit your needs until you are done), save it to My Maps and download it as KML. Then you can use GPSBabel to convert it to GPX, which you can copy to the Garmin device:

gpsbabel -w -i kml -o gpx -f route.kml -F route.gpx

By doing this, you have to rely on the feature that allows the Zümo to convert a track into a route. So, if you didn’t know: you can import a recorded track from any source into your Zümo, and the Zümo will calculate it into a route. This approach gives you a route that matches exactly what you prepared, but has two major drawbacks:

  • Tracks are made up of many (possibly thousands) of waypoints. Having the Zümo convert this into a route takes a long time, and there is a big risk that the Zümo will not have enough memory to process the whole track, which leaves you with an incomplete route. Rendering this type of route on the map is also slower, although that may be just my impression.
  • The resulting route does not have any “route waypoints”, as discussed above. It will just have a start and finish. When you drive the route, and underway you have to recalculate the route (roadblocks, detours, you missed an exit, stuff like that), it will then calculate route directly to the finish according to the device’s route settings. Any modifications you made by hand in Google are now lost. You can get them back by reloading the route from the menu, but it’s up to you to find your way back to it.

There is another way, which does give you a route with route waypoints, it’s just a little more work.

When you drag your route in Google Maps to a diffent road, Google marks that point with a small white dot with a black border. These are our route waypoints. Create as many as you need, but not too many because of the next step.

When your route is finished, create a placemark on every route waypoint that you added. Placemarks are to Google what waypoints (the regular kind) or favorites are to Garmin. If you have a highly customized route, this can be some work. Sorry about that. Make sure that the order in which the placemarks appear in the list on the left hand side of the screen match the order in which they appear in the route. Also make sure that you do not have any placemarks that are not part of your route.

When you are done, download the route as KML. We will now use GPSBabel to construct a route from the placemarks in the KML file.

gpsbabel -i kml -o gpx -f route.kml -x transform,rte=wpt -x nuketypes,waypoints,tracks -F route.gpx

This does a couple of things:

  • Convert KML into GPX
  • Using the transform filter, create a route from all waypoints (placemarks)
  • Discard all waypoints and tracks, using the nuketypes filter

The last step is there to make sure that the Zümo will not try to import all the route waypoints as regular waypoints (so they show up in your Favorites), and we don’t need the track either. If you want to keep the track, for example to compare the results, you can leave out the tracks option from the nuketypes filter.

So, an example. First click here to open my example in Google maps. And here’s how the final result looks on the Zümo:

Google  thinks this route is 593 km, the Zümo thinks it’s 586 km. That sounds about right, doesn’t it?

Just one more thing to keep in mind: Google’s routing engine is different from the Zümo’s, and your Zümo also takes your settings into account when calculating, like whether to get the quickest or the shortest route, which types of roads to avoid, etc. If you want the result on the Zümo to closely match what you created in Google, make sure you have enough waypoints. The more waypoints you have, the closer they are to each other, and the fewer possible roads there are to get from one waypoint to the next. It’s as simple as that 🙂

Vaag motorritje

Zondag ben ik een stukje gaan motorrijden, zoals wel vaker. ‘t Is alleen nogal een maf rondje geworden, met vooral wat doodlopende stukjes:

 

Dit soort dingen is altijd weer aanleiding om m’n GPS tooltjes weer eens te bekijken en zo nu en dan wat nieuws uit te proberen. Zo ontdekte ik vandaag een programma genaamd ‘Viking‘. Het heeft vaag iets weg van een primitieve versie van MapSource, maar het kan ook wel wat dingen die MapSource niet kan. Ik moet er nog eens wat verder mee spelen, maar wat ik er tot nu toe mee gedaan heb, en wat prima ging, was een specifieke track uit een backup van mijn Garmin wegschrijven als GPX bestand.

Dit GPX bestand heb ik vervolgens met GPSBabel omgezet naar KML. Voor de volledigheid (en ter referentie voor mezelf) plaats ik hier de volledige GPSBabel invocatie:

gpsbabel -t -i gpx -o kml,points=0,line_color=A00000FF,line_width=4 -f <gpx-file> -F <kml-file>

Dit zorgt ervoor, dat er geen storende “placemarks” in de KML komen, en dat de track wordt weergegeven met een lijn van 4 pixels breed, in de kleur rood, met een opacity van 0xA0, wat neerkomt op ongeveer 60%.