Openstreetmap data for Gamin Devices

OpenStreetMap provides maps which can be used by everybody. In order to use OSM data in GPS devices, especially on Garmin devices, several programmes and data are available (see OSM-Wiki): Since the several steps are to be performed, I put the following python script osm2img.py together, which downloads OSM data and calls splitter and mkgmap in order to produce a gmapsupp.img usable in a Garmin device.

Disclaimer: This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

Usage: osm2img.py [options] config.ini

generation of Garmin maps from OpenStreetMap

Options:
  -h, --help            show this help message and exit
  --createconfig=DIR    create config file in directory DIR

  -b, --downloadbounds  download bounds files (needed only once). Overwrites existing files
  -d, --download        download osm.pbf files (needed for any update). Overwrites existing files
  -s, --split           split osm.pbf files (deletes existing splitter results)
  -m, --mkgmap          create img tiles (Deletes existing .img files)
  -J                    use osmosis to join the country pbf files into a single pbf file to improve routing
  -j, --join            if -J is used join input pbf files to obtain a single input file
			else join country .img files into a single gmapsupp.img (Overwrites existing gmsupp.img)
                        if -J is given, join input pbf files
  -a                    country by country instead of action by action
  -S                    simulate only (andprint actions to screen)

So, fo instance if you need the maps for France, Germany, Benelux, Andorra and Monaco, with a config.ini as shown below you could create your gmapsupp.img by

  osm2img.py -bdsmj config.ini
The option -b downloads the boundary-file and seas-file (from http://www.navmaps.eu). Since these data do not change often, you do not need to use this option again.

The resulting outputdir/gmapsupp.img (nearly 2GB in size with the configuration shown below) can be copied onto the SD card of your Garmin device (some devices like my nĂ¼vi 1390T want the file in a subdirectory Garmin/gmapsupp.img). For newer Garmin devices, it may suffice to copy the country img files (like outputdir/France/France.img etc.) into the subdirectory map) on the SD card. If your device is capable of this, the -j needs not to be used. Under no circumstances replace the original gmapsupp.img or any other file of you Garmin device! Otherwise you will irreplacebly destroy your original map data. Use only a micro SD memory card to add OSM data to you Garmin device. As said above I decline any responsability for any damage which may occur, even if you follow all instructions correctly. It's your Garmin device, You must know what you do, otherwise don't!

Installation

Configuration file

[Local]
# define the codes of countries which should be in the final data 
# (see section [Global] for the definitions of these codes
countries=AND, BEL, DEU, FRA, LUX, MCO, NDL


# short label and long label for the final gmapsupp.img file
# if absent the label/long label of the first country is taken
outlabel=EU
outname=Europe

# working directory 
workingdir=/home/johannes/OSM/mymapdir

# Garmin device maps need a family ID. 
familyID=22

[Input]
# URL where we can find osm.pbf files for countries
osmdumpshost=http://download.geofabrik.de/openstreetmap

# bounds files (needed by mkgmap) which defines international borders
# the name of this file changes regularly. Check on http://www.navmaps.eu/wanmil/
bounds=http://www.navmaps.eu/wanmil/bounds_20130308.zip
sea=http://www.navmaps.eu/wanmil/sea_20130308.zip


[Global]
# global directory, used for definitions below. The value of this
# variable can be used as %(mydir)s in all other path definitions
mydir=/usr/share/osm2img

# directory where to find osmosis executable (see http://wiki.openstreetmap.org/wiki/Osmosis)
osmosisbin=%(mydir)s/bin/osmosis/bin/osmosis

# directory where to find the splitter jar files (including the lib-directory)
# splitter and mkgmap are available via http://wiki.openstreetmap.org/wiki/Mkgmap
splitterdir=%(mydir)s/tools/splitter-r283

# directory where to find the mkgmap jar files
mkgmapdir=%(mydir)s/tools/mkgmap-r2484

# directory where to find the style for mkgmap (see mkgmap pages for more information of how to modify)
mkgmapstyledir=%(mydir)s/jhe-style

# maximal number of nodes (used by splitter.jar). Use smaller number for very dense areas
# for European states 1 000 000 works nicely. The default value by spliiter.jar is 1 600 000
maxnodes=1000000

# defines colours and some icons used in final file
# more information available at http://wiki.openstreetmap.org/wiki/Mkgmap/help/TYP_files
typfile=%(mydir)s/jhetyp.txt


# country abbreviation (iso), country name, URL (using osmdumps), MAP-id prefix  (must be unique per country, here we use the telephone code), optional encoding to use if not cp1252
# Feel free to complete!

FRA=France, europe/france, 033
BEL=Belgium, europe/belgium, 032
DEU=Germany, europe/germany, 049
LUX=Luxembourg, europe/luxembourg, 352
NDL=Netherlands, europe/netherlands, 031
GBR=United_kingdom, europe/great_britain, 044
IRL=Ireland, europe/ireland, 353
AND=Andorra, europe/andorra, 367
MCO=Monaco, europe/monaco, 377
    
AUT=Austria, europe/austria, 043
PRT=Portugal, europe/portugal, 351
ESP=Spain, europe/spain, 034
ITA=Italy, europe/italy, 039
POL=Poland, europe/poland, 048
CHE=Switzerland, europe/switzerland, 041
CZE=Czech_republic, europe/czech_republic, 420
DNK=Denmark, europe/denmark, 045

ALB=Albana, europe/albania, 355
BLR=Belarus, europe/belarus, 375,  cp1251
BIH=Bosnia, europe/bosnia-herzegovina, 387
BGR=Bulgaria, europe/bulgaria, 359,  cp1251
CYP=Cyprus, europe/cyprus, 357
HRV=Croatia, europe/croatia, 385
EST=Estonia, europe/estonia, 372
FIN=Finland, europe/finland, 358
FRO=Faroe, europe/faroe_islands, 298
GRC=Greece, europe/greece, 030,  cp1253
HUN=Hungary, europe/hungary, 036
ISL=Iceland, europe/iceland, 354
IRL=Eire, europe/ireland-and-northern-ireland, 353
LVA=Latvia, europe/latvia, 371
LIE=Liechtenstein, europe/liechtenstein, 423
MKD=Macedonia, europe/macedonia, 389
MLT=Malta, europe/malta, 356
MNE=Montenegro, europe/montenegro, 382
ROU=Romania, europe/romania, 040
RUS=Russia, europe/russia-european-part, 007,  cp1251
SRB=Serbia, europe/serbia, 381,  cp1251
SVK=Slovakia, europe/slovakia, 421
SVN=Slovenia, europe/slovenia, 386
SWE=Sweden, europe/sweden, 046
TUR=Turkey, europe/turkey, 090,  cp1254
UKR=Ukraine, europe/ukraine, 380,  cp1251

Lookig forward to your comments!


Last changes on 28th March 2016 (jhe)