cycling africa

OpenStreetMap: Custom Areas for the Garmin GPS

I’m using OpenStreetMap data as my primary means of navigation. For backup and overview I also have paper maps. Those are mostly Reise Know-How world mapping project maps. The ones for Eastern Europe have been great, as has the Uganda one. The Tanzania maps has some errors, distances are sometimes off and the size of towns/villages listed (which is an important indicator for whether you’ll find accommodation there) is not always accurate.

But back to OpenStreetMap, here’s something I learned along the way and how I prepare the maps for my GPS device:

Here in Africa where I’m now the amount of OpenStreetMap map data even for a huge region is not that big. There’s just not as many details in the map data here (so having to deal with more data is actually a problem I’d really like to have). That means I can easily compile the whole continent of Africa into a single map and use that for navigation.

In Europe it’s not that easy – but again, that’s a good problem to have! While the whole continent of Africa currently has 365 MB the map data for Germany alone is 2.1 GB. This makes converting the maps into the Garmin format slow and – that’s the real problem – my device (Garmin GPSMap 62s) can hardly handle map files that big.

So the first thing that came into my mind was: just use individual countries (or subregions if still to big) and generate individual map files for those. Geofabrik offers this great service where you can download the raw data for individual regions. I opted not to download single countries but the continents (Europe and Africa) and use the shape files provided by CloudMade (which seem to no be available any more) to extract the data for single countries. On those I applied the usual tools (mkgmap and splitter) to generate Garmin map files.

This works great while you are not to close to any border…

My idea was to activate the next map every time I was about to cross a border (and disable the ones I don’t need to save ressouces on the GPS). But that does not work well, near the border I would often only get blank areas and messed up map display. Maybe the shape files are not well aligned to each other? Or I messed up the splitting? Anyway, the result near borders sucked, I wanted something better.

So what I ended up doing was not using national or regional political borders as boundaries for my maps but just create an individual one that makes sense for the route I was going to travel. This way I would never get close to the edge of my map. Here’s how I did that:

First I’m using JOSM to draw a polygon around the area I want in my map.

Draw polygon in JOSM

Next you need to save that polygon to a file in a format usable by osmosis. JOSM can’t do that out of the box but there’s a plugin and it’s installation is quick and easy:

JOSM install poly plugin

JOSM save polygon

Now that we have the map boundaries as a polygon in a file we can use osmosis to extract the map data for that region. You could use the complete planet dump but here I’m using the Europe file which I got from the Geofabrik download service mentioned above. This speeds things up considerably.

1
2
3
4
$ osmosis \
    --read-pbf file=europe.pbf \
    --bounding-polygon file=southeast-europe.poly \
    --write-pbf file=southeast-europe.pbf

Next are the steps specific for the garmin format. We apply splitter and mkgmap to convert the raw OpenStreetMap data into that format:

1
2
3
4
5
6
7
8
9
10
11
12
$ java -Xmx3000M -jar splitter.jar southeast-europe.pbf

$ java -Xmx4000M -jar mkgmap.jar \
    --route \
    --gmapsupp \
    --index \
    --tdbfile \
    --precomp-sea=sea_20140916.zip \
    --bounds=bounds_20140916.zip \
    --preserve-element-order \
    --description=OSM_Southeast_Europe \
    *.osm.pbf

Splitter – as the name implies – again cuts the map data into smaller chunks. This has purely technical reasons, mkgmap can’t handle input files that are too big. But this does not have any effect on the end result, all the intermediate files are concatenated into one single map at the end.

And there we have it, a map tailor made for my trip :)

I usually use QLandkarte GT for a quick inspection of the resulting file and then copy it to the Garmin to use on the road.