Mkgmap/help/How to create a map

From OpenStreetMap Wiki
< Mkgmap‎ | help
Jump to: navigation, search
Available languages — Mkgmap/help/How to create a map
Afrikaans Alemannisch aragonés asturianu azərbaycanca Bahasa Indonesia Bahasa Melayu Bân-lâm-gú Basa Jawa Baso Minangkabau bosanski brezhoneg català čeština dansk Deutsch eesti English español Esperanto estremeñu euskara français Frysk Gaeilge Gàidhlig galego Hausa hrvatski Igbo interlingua Interlingue isiXhosa isiZulu íslenska italiano Kiswahili Kreyòl ayisyen kréyòl gwadloupéyen Kurdî latviešu Lëtzebuergesch lietuvių magyar Malagasy Malti Nederlands Nedersaksies norsk bokmål norsk nynorsk occitan Oromoo oʻzbekcha/ўзбекча Plattdüütsch polski português português do Brasil română shqip slovenčina slovenščina Soomaaliga suomi svenska Tiếng Việt Türkçe Vahcuengh vèneto Wolof Yorùbá Zazaki српски / srpski беларуская български қазақша македонски монгол русский тоҷикӣ українська Ελληνικά Հայերեն ქართული नेपाली मराठी हिन्दी অসমীয়া বাংলা ਪੰਜਾਬੀ ગુજરાતી ଓଡ଼ିଆ தமிழ் తెలుగు ಕನ್ನಡ മലയാളം සිංහල ไทย မြန်မာဘာသာ ລາວ ភាសាខ្មែរ ⵜⴰⵎⴰⵣⵉⵖⵜ አማርኛ 한국어 日本語 中文(简体)‎ 吴语 粵語 中文(繁體)‎ ייִדיש עברית اردو العربية پښتو سنڌي فارسی ދިވެހިބަސް
Mkgmap
Help
Routing
i18n
Known issues
Development
Download maps

Introduction

If you want to load OSM data onto a Garmin GPS device, you can either download pre-compiled maps, or you can compile them yourself. This page describes the latter option. The maps produced support routing (for cars) and searching for addresses.

Pre-Requisites

You need to download the following software / tools:

Install Java Runtime Environment 1.7. Both mkgmap and splitter depend upon it.

Walkthrough

Download OSM data (.osm, .osm.pbf or .osm.gz) for a certain region. Mirrors offering extracts are listed here. Geofabrik and Cloudmade are good starting points.

Use splitter to split the raw map data into smaller pieces, called tiles. This is necessary because most of the downloaded region extracts are too big to be processed by mkgmap. For example:

$ java -jar splitter.jar us-northeast-latest.osm.pbf

The resultant tiles are named 6324xxxx.osm.pbf, where xxxx is 0001, 0002, 0003...

These tiles can be compiled into a map as-is, but the resultant map would lack addressing data (e.g. city or zip code). Addressing data comes from preprocessed bounds tiles, and you can either download them from mkgmap.org or create them yourself as described in Mkgmap/help/options#Using_preprocessed_bounds_for_the_address_index. Place the resultant files into a subdirectory named bounds.

Finally, you can use mkgmap to compile the tiles and bounding information into something comprehensible by a Garmin GPS.

$ java -jar mkgmap.jar \
    --route \
    --add-pois-to-areas \
    --bounds=bounds \
    --index \
    --gmapsupp \
    6324*.osm.pbf

This creates several files, including the coveted gmapsupp.img file. Copy this file onto the SD card used by the GPS. The details are listed here, but here's a quick refresher:

  • The SD card should be formatted as FAT32.
  • There should be a folder called "Garmin" at the root of the SD card.
  • The gmapsupp.img goes into the "Garmin" folder.

Tweak your map

You can use several options and the style files of mkgmap to tweak your map to your requirements. Read the following for details:

Detailed custom map creation and integration in BaseCamp

This is a more detailed tutorial for the creation of the French road network accessible to cars (in order to update a nüvi 250 gps device) and the creation of an installator to enable using the map on Garmin Basecamp program in windows.

Pre-requisites

We tested the following on Ubuntu 14.04 and the installer on windows 10

software / tools:

  • Java Runtime Environment from http://www.java.com
  • mkgmap (r3676)
  • splitter (r437)
  • osmconvert (0.7T) (can be installed via the debian/ubuntu package osmctools using) ~.../map$ sudo apt-get install osmctools
  • makensis (can be installed via the debian/ubuntu package osmctools using) ~.../map$ sudo apt-get install nsisWe work from a folder named "map" from which we can run "splitter.jar" and "mkgmap.jar". This can be made by downloading the "mkgmap-r3676.zip" and "splitter-r437.zip" files from http://www.mkgmap.org.uk/download/ in our current folder "map", extract the archives content there, then create a symbolic link to the .jar files in our current folder ~.../map$ ln -s ./mkgmap-r3676/mkgmap.jar mkgmap.jar.

    OpenStreetMap data:

    We download up-to-date osm data from the geofabrik server (France data) : france-latest.osm.pbf. The .pbf format used here is a binary format much more compressed than the original xml human readable .osm format. For our project we would like to use a somehow in between choice using .o5m that is faster to write than .pbf using osmconvert tool: osmconvert france-latest.osm.pbf france-latest.o5m.

    Preprocessed OpenStreetMap data:

    We will ask Mkgmaps to encode post adresses of places in order to find them on our gps. Also we will ask it to define blue patches for seas. Those elements are not defined directly as openstreetmap objects, but by indicating their boundaries. In order to define which elements are inside the bondaries or not, those former have to be processed first. This process generates files useful to generate adresses and sea area. Up-to-date Sea and administrative preprocessed boundaries can be downloaded from the mkgmap web site (files Sea.zip and bounds.zip).

    Reference places data:

    The list of cities populated with more than 1500 persons is kept by the geonames project. Download cities15000.zip in order to automatically label splitted map tiles from splitter

    Walkthrough

    First we will use splitter to split our large france-latest.o5m file in smaller processable files in the same format:

    ~.../map$java -jar splitter.jar france-latest.o5m --output=o5m --output-dir=francesplittertempfile --max-areas=4096 --max-nodes=3000000 --wanted-admin-level=8 --geonames-file=cities15000.txt > francesplitter.log
    
    Please note that I adapted the maximum size and number of nodes allowed in the output files in order to limit the number of tiles in the final Garmin .img map, on the other hand it augment the risk of running out of memory in the next steps... I asked to keep element linked together up to the level of the cities because it seemed that obtained better address search results this way.

    This step produces a new folder ./francesplittertempfile and a log file francesplitterlog in our current directory. The new folder contains among others a mkgmap option file template.arg with name and description field of all the 6324xxxx.o5m files of the subregions generated by the operation.

    Second, we will generate our custom mkgmap style rule files that contains all the rules about how to process the osm objects/include them in the .img files. We will start modifying the default style file that can be found in ~/map$./mkgmap-r3676/examples/styles/ and make a copy the default folder in our map folder to edit the rules with name road_only.

    We let the options file as it is. New style description can be updated in the info file. In relations, lines, and points we comment all the line corresponding to elements that we do not want to show in the map (OSM object that are not covered by a rule are disregarded by default). Hence in the points file, we comment all the lines but those that correspond to car necessities, routing and addressing:

    • place=...
    • amenity=fuel ...
    • amenity=parking ...
    • highway=...
    • <finalize> name=* { name '${name}' } include 'inc/address';

    an include line is used for readability and refer to another file that is incorporated as it is. Thoses files such as road_only/inc/address must be checked also...

    Third, we will use mkgmap program to generate the garmin .img maps note that options order matters a lot:

    ~.../map$java -jar mkgmap.jar --max-jobs --gmapsupp --tdbfile --nsis --output-dir=OSMFRANCE_light --mapname=OSM_FRANCE_light --country-name="FRANCE" --family-id=6324 --family-name="OSM_light france 2016" --series-name="OSM france map" --area-name="France" --country-abbr="FRA" --style-file=./road_only --precomp-sea=sea.zip --generate-sea --route --drive-on=detect,right --process-destination --process-exits --index --bounds=bounds.zip --location-autofill=is_in,nearest --x-split-name-index --housenumbers --remove-ovm-work-files --verbose -c ./francesplittertempfile/template.args
    

    Fourth we will build the windows installer for Basecamp map usage running the script osmmap.nsi automatically generated by mkgmap to makensis:

    ~.../map$ makensis ./OSMFRANCE_light/osmmap.nsi
    

    Note that the .img files are compressed in the installer. By default, mkgmap generates a building script asking for a lzma compression that has excellent compression ration and extraction time properties but can takes a very long time to complete. You might be interested to build a bigger file in less time using the simpler zlib compression algorithm by changing the corresponding option value line in the .nsi script file befor you build the installer (using sed -i 's_SetCompressor /SOLID lzma_SetCompressor /SOLID zlib_g' ./OSMFRANCE_light/osmmap.nsi)

    (Once the installer is build, all 6324xxxx.img files can be deleted using for i in "./$DIR/6324*.img"; do rm $i; done)