OSM Map On Garmin/Using POIs from OSM along with Garmin Maps

From OpenStreetMap Wiki
Jump to: navigation, search

Why would I want to mix commercially supplied maps with POIs from OSM?

The quality of the commercially supplied maps from Garmin is not too bad - if you want to navigate your car on highways in an industrialized country, chances are, as of 2011, that the correctness of routing and especially additional features like "lane assistency" will be better than if you used OSM-derived maps on your Garmin device. (That is, of course, only if updated your commercially supplied maps recently.)

On the other hand, the Garmin supplied maps are woefully inferior to OSM regarding their "amenity"-listings, especially in densely populated areas. I can say for sure that e.g. "restaurants in Frankfurt/Germany" are very incomplete and outdated even in the most recent Garmin maps that I installed.

So while I intend to keep using the commercial maps in Germany for routing, for now, I want to combine them with the better completeness and accuracy of the "amenities" available from OSM.

Another reason for using additional POIs is the unwillingness of some Garmin devices (e.g. the nüvi 3790) to render icons on the map display for POIs that are part of their maps - for whatever reason - but at the same time those Garmin devices will happily render icons for POIs defined in custom installed POI files...

Sample Display of Garmin Nüvi 3790 with *.gpi files installed that were created from the OSM planet file

Available methods for adding POIs to Garmin nüvi 3790 devices

(I don't know how specific what I write here is for the nüvi 3790 model, firmware 4.7, it might certainly work with other 3xxx models, as well.)

Using *.gpi files

The Garmin device allows to put an arbitrary number of *.gpi files into a sub-directory called poi/ on either the VFAT filesystem that resides on the builtin flash-RAM (exposed as an USB-storage device, when the device is connected to an USB-host like a PC) or on the VFAT filesystem that resides on any microSD flash memory card that you put into your Garmin device.

Pros
Well documented method, kind of precisely meant for what we want to accomplish. Allows to have the Garmin nüvi 3790 render icons on the map display for POIs. Positively tested to work well even with lots of POIs - e.g., putting all 850,000 bus stations currently defined "bus_stop"s into one *.gpi file and using it on the Garmin device works just fine.
Cons
POIs stored in *.gpi files are searchable only in a somewhat cumbersome way, by choosing "Navigate to" / "Extras" / "User defined POIs". You cannot use voice commands to search for them. You cannot search in one go through all POIs, including both the Garmin provided ones and the ones you added.

Using *.gpx files

The Garmin device allows to put an arbitrary number of *.gpx files into a sub-directory called gpx/ on either the VFAT filesystem that resides on the builtin flash-RAM (exposed as an USB-storage device, when the device is connected to an USB-host like a PC) or on the VFAT filesystem that resides on any microSD flash memory card that you put into your Garmin device.

When the Garmin device is switched on (after transferring the *.gpx files to it), it will integrate the content of the *.gpx files into the /gpx/Current.gpx file in its builtin flash-RAM. The transferred *.gpx files remain untouched (and unused) otherwise.

To use the POIs in /gpx/Current.gpx, you have to use the "Navigate to" / "Favorites" menu.

Pros
Well documented method. The amenities are represented by appropriate icons and labels on the display of the Garmin device, when looking at the map.
Cons
An upper limit of 999 entries is enforced by the Garmin device regarding the size of the /gpx/Current.gpx file - so you can essentially not store any more POIs than this using this method. This is kind of a killer argument against this method, as even the number of restaurants in any serious city exceeds 1000.

Using *.img files

The Garmin device allows to put an arbitrary number of *.img files into a sub-directory called map/ on either the VFAT filesystem that resides on the builtin flash-RAM (exposed as an USB-storage device, when the device is connected to an USB-host like a PC) or on the VFAT filesystem that resides on any microSD flash memory card that you put into your Garmin device.

To use POI data that is part of *.img files, you have to enable those maps in the "Preferences" / "System" / "myMaps" dialog.

Pros
Smallest storage size on the device. Integrates seamlessly with the voice- or keyboard-driven commands for searching destinations on the Garmin device - e.g., you'll find "Restaurants" as POIs of type "Restaurant", along with all the restaurants that are listed in the Garmin supplied maps.
Cons
There will be duplicates in your search results when you add POIs that the Garmin supplied maps already contained. (I consider this a minor annoyance.) No icons are displayed for POIs on nüvi 3790 when displaying maps (for whatever reason, this has been a subject of criticism from nüvi 3790 users towards Garmin for quite some time, already, and it seems completely illogical since the "Favourites" and "Customer supplied POIs" are rendered as icons on the map).

How to extract the relevant POIs from OSM

Obtain OSM data

Refer to the "Planet" page on how/where to download *.osm or *.pbf files for the area you consider relevant. To save downloading time, you may want to prefer downloading the *.pbf variant.

Filtering just the POIs of your choise

Best use Osmosis to extract only the nodes of the POIs that you are interested in from the downloaded OSM data file. Most likely, those POIs will be an "amenity" of some kind. The following is an example on how to invoke Osmosis to extract only the restaurants from a file called "germany.osm.pbf" that you may have downloaded:

osmosis --read-pbf file=germany.osm.pbf \
        --node-key-value keyValueList="amenity.restaurant" \
        --write-xml file="german_restaurants.osm"

You will notice that while the input file "germany.osm.pbf" is (currently) 1.1GB in size, the output file ""german_restaurants.osm"" is only 18MB - even though it is written in the much less efficient ".osm" (XML-based) file format.

Notice that you can save a lot of time by extracting multiple *.osm files for different amenities from your input OSM data file in just one run of the osmosis tool: The osmosis command line syntax allows you to create a "tee"-junction for the processing pipeline and using the different ends to filter the data for multiple output files.


The following conversions to files that you can upload to your Garmin device will use such filtered .osm files as input.

Converting .osm to .gpi files

Use GPSBabel - this software can read (among many other formats) *.osm files and write *.gpi or *.gpx files. GPSBabel cannot read *.pbf files, and it cannot write *.img files, though.

Example usage:

gpsbabel -i osm -f german_restaurants.osm \
         -o garmin_gpi,category="Restaurants",bitmap="restaurant.bmp" \
         -F german_restaurants.gpi

This will result in a new file "german_restaurants.gpi" that you can store to a poi/ directory on your Garmin device.

IMPORTANT: If you create multiple *.gpi files, of if you copy multiple pre-existing *.gpi files to your Garmin device, please make sure those files all get a different time stamp (e.g. by waiting 2 seconds in between each file creation / copy). As unusual as this sounds: The Garmin software obviously makes use of those file time stamps to memorize which files it already processed...

Please notice that two features of GPSBabel will significantly slow down the conversion process for large amounts (> ~ 100,000) of POIs:

  • By default, GPSBabel will try to create unique names for all POIs. For many kinds of POIs, there is no good reason to do so - it simply doesn't help if you have your GPS device list two bus stops as "Bus Stop1" and "Bus Stop2" instead of naming them both "Bus Stop". So you should consider adding ",unique=0" to the parameter for "-o", disabling the unique name generation.
  • GPSBabel, as of December 2011, tries to filter out duplicate POIs from the input, by applying certain comparisons. This is not too useful for OSM data as input, which does not usually contain such duplicates, anyway, and the way this feature is implemented is kind of CPU intensive. You can remove this feature from GPSBabel only by changing its source code: Find the function "enum_waypt_cb" in the file "garmin_gpi.c", then remove the following lines of code there:
 QUEUE_FOR_EACH(&wdata->Q, elem, tmp) {
   waypoint* cmp = (waypoint*) elem;
   
   // sort out nearly equal waypoints 
   if ((compare_strings(cmp->shortname, ref->shortname) == 0) &&
       (cmp->latitude == ref->latitude) &&
       (cmp->longitude == ref->longitude) &&
       (compare_strings(cmp->description, ref->description) == 0) &&
       (compare_strings(cmp->notes, ref->notes) == 0)) {
       return;
   }
 }

Converting .osm to .img files

Use mkgmap, which can read *.osm and *.pbf files and write *.img files. (mkgmap cannot cannot write *.poi or *.gpx files.)

Example usage:

mkgmap -n 12345678 --family-id=1234 --family-name="MyPOImap" --description="Map of German Restaurants" \
       --country-name="Germany" --country-abbr="GER" --code-page=1252 --lower-case \
       --index --location-autofill=bounds,nearest,is_in --make-poi-index \
       --gmapsupp german_restaurants.osm

This will result in a new file "gmapsupp.img" being written to the current working directory - you should rename this file to something more useful like "german_restaurants.img", then copy it to a map/ directory on your Garmin device.

Script and Icons for automated *.gpi generation

I have prepared a small Tcl script and painted some icons for common amenities that seemed reasonable to upload to a Garmin device. Alas, I am supposed not to upload those mere 15kB here, because this Wiki does not allow to upload script code or archive files.

If you happen to know somebody who would be interested and willing to host this script - or maybe even the much bigger (~ 200MB) ready-made *.gpi files that contain amenities for the whole planet - drop me a note. --FFMnative 17:55, 10 December 2011 (UTC)