OpenStreetMap on your Garmin GPS

OpenStreetMap on your Garmin GPS

(by Peter O’Neill, February 2013)
You’ve bought a Garmin GPS, but your budget does not stretch to the extra mapping needed to make it a useful tool on the hill. GroundTruth (software) and OpenStreetMap data may be the answer.

Compare the screens below from my Garmin eTrex Summit HC, which has 24MB capacity for uploaded maps. (This unit does not support screenshot download, so these are photographs of the 1.3” wide x 1.7” high screen)

Garmin built-in mapping        OpenStreetMap mapping

  
Wicklow – Turlough Hill

  
Mautino Hut towards Col Bousson (route on Garmin eTrex)

  
Abisko – Abiskojaure(saved track on Garmin eTrex)

The additional detail in these maps using OpenStreetMaps is immediately obvious. You can check what will be available by viewing the area of interest at openstreetmap.org – as this is a project which depends on users to input map data, coverage will vary from area to area. You might later even consider adding map data yourself for areas where you find detail missing, using the traces on your GPS.

24 MB for map storage may seem rather small to readers accustomed to modern electronic devices (to put that in context for younger readers, it exceeds the total capacity of all disks held by my first employer for their IBM mainframe computer), but this is sufficient to simultaneously hold maps of Wicklow, a good chunk of the Pyrenees, most of the Lot, and a chunk of the Alps. You are not limited to uploading a map of a single area, and can easily replace one set of maps by another set.

The colour schemes used in different areas for linear features in OpenStreetMap data can be somewhat quirky, as can be seen in the Turlough Hill screenshot — blue for example is more usually associated with water features rather than tarmac — but in practice I’ve not found it worth bothering to fine tune the colour scheme, although possible in principle, for each area processed for transfer to the GPS. You may need to add detail which is missing in the OpenStreetMap data: for example, there is a marshy area with a small lake/large pond, Lago di Fontana Fredda, just before Col Bousson on the route from Capanna Mautino, and some smaller ponds on the French side, which are not mapped in the OpenStreetMap data, but which might be a problem if disguised by a thin layer of snow (not a problem though when I crossed last time — there was a good 150+ cm). I simply add a waymark, the small blue flag labelled “Lago” near the bottom of the screenshots, as a reminder to avoid such missing features. (See the end of this article however for a note regarding the latest data). These two screenshots also show the rather rough nature of linear features such as country boundaries, seen here near that small lake, in the built-in mapping.

The third pair of screenshots shows that a useful map may still be obtained even when contour information is not available. Contours used here come from a NASA dataset, but this dataset only covers a range from 56°S to 60°N. The main features in the area shown are water features in any case, with some tracks near Abisko. If that track across the lake, Abiskojaure, leads you to doubt the accuracy of the mapping, rest assured that it is accurate — you simply didn’t know that walking on water was one of my many talents. Of course, it did help that that lake was still frozen solid (with an appropriate “own risk” warning), other than at the small inlet at the south-western end, where care was needed approaching the shore at the Abiskojaure huts (warden’s cottage plus two huts).

So, how do you process OpenStreetMap data to obtain maps which can be uploaded to a suitable Garmin GPS? This is the promised fuller version of the February 2013 newsletter article, with the steps below described and illustrated in detail, for anyone who wants to try the process.

The first thing you may notice if you download GroundTruth is that this is Windows software. It can be run on Linux if the Mono Framework is installed, but if you are a Linux user you are on your own here. Garmin has no Linux support. As it is possible to transfer maps to a Garmin device without using a Garmin MapSource product, using a program called sendMap20 which runs on both Windows and Linux, you will need this if working with Linux.

As for Mac, Garmin do have support for Mac OS 10.4 and higher (although the software CD for my Summit HC simply said “Not Mac compatible”). GroundTruth however uses a program, cGPSmapper, which runs on Windows and Linux, but not on Mac. You might try running Linux in a VM on your Mac to get around this problem. You can find information on Garmin Mac support at http://www8.garmin.com/osx/.

Download GroundTruth from http://downloads.igorbrejc.net/osm/groundtruth and unzip the package.

Download the latest free version of cGPSmapper (there are commercial versions as well, needed if you intend to sell maps) from http://www.cgpsmapper.com/buy.htm (for Windows this should be the exe-only zip file, not FreeSetup.exe), and unzip it into the same directory as GroundTruth.

There is an introduction to the process at http://wiki.openstreetmap.org/wiki/GroundTruth_For_Dummies which you may like to read. If you do, you may notice that I have omitted (optional) steps 6 and 7 of the Windows installation instructions there, on the assumption that you will use a Garmin MapSource product to upload your maps. These steps install sendMap20, downloadable from the cGPSmapper site, which will be needed if working with Linux. Further information about GroundTruth can be found at http://wiki.openstreetmap.org/wiki/GroundTruth and http://wiki.openstreetmap.org/wiki/GroundTruth_FAQ and the GroundTruth manual is at http://wiki.openstreetmap.org/wiki/GroundTruth_Manual (reading these documents is not essential if working with Windows, as you should have enough information below; reading “GroundTruth for Dummies” would be advisable if working with Linux)

Once GroundTruth and one other associated utility have been downloaded and installed:

  • Select a rectangle defining by latitude and longitude (“bottom left” and “top right”) the extent of the map to be produced. As this rectangle would otherwise need to be specified both when downloading contour data and when downloading OpenStreetMap data, a batch command file can be found below which allows the next three steps to be run supplying this rectangle only once, together with some further parameters to generate maps which can coexist with each other, without needing to read the manual.
  • Download the contour data for this rectangle
  • Download the OpenStreetMap data for this rectangle
  • Combine the downloaded data to produce the map, making sure that the map files produced can be used without conflict with the files for any other map

GroundTruth is run from a command line. So it can be run using a batch command file. I call this go.bat, and you can create your own by copying the following lines into Notepad, turning the indented lines into continuations of the previous lines, and saving as a bat file by changing the “Save as type” from “Text Documents (*.txt)” to “All Files (*.*)”, and specifying the file name as “go.bat” (and the quote marks are needed here). This file should be saved in the same directory as GroundTruth, and should be run from a command prompt where this directory is the current directory.

GroundTruth.exe contours -b=%4,%5,%6,%7 
set /a N = 0 
set /a SM = 0 
:again 
set /a N = %N% + 1 
pause 
time /t 
GroundTruth.exe getdata -b=%4,%5,%6,%7 
  -osmxapiurl="http://open.mapquestapi.com/xapi/api/0.6/*" 
echo off 
set /a errl = %errorlevel% 
set /a SM = %SM% + %errl% 
 
echo ( %N% ) ( %SM% ) errorlevel: %errl% 
if errorlevel 1 goto again 
echo on 
pause 
GroundTruth.exe makemap -ibf=output.ibf -osmfile=output.osm 
  -rules=RulesHikingMapRules.txt -outputpath=%1 -fc=%2 -fn=%3 -pn=%3 %9 
 
rem     Dir  Code Name                MinLat MinLon MaxLat MaxLon ... 
rem  go MapA  2   GroundTruth_Abisko  67.8   18.0   68.5   19.1   12345278 
rem  go MapM  3   GroundTruth_Mournes 53.95  -6.4   54.3   -5.85  12345978 -nosea

A few comments on this go.bat file are appropriate here. You will have noticed that it does more than simply run GroundTruth three times, once for “contours”, once for “getdata” and once for “makemap”. The reason for this is that the “getdata” step frequently fails, either before or during data download, and may need to be tried repeatedly until it succeeds. The go.bat file checks for a returned error code, and tries again if there has been an error. Processing pauses before each “getdata” attempt, and after success. Continue by pressing Enter.

To keep track of the parameters used for each map produced, to avoid future conflicts, I edit the go.bat file after each map is produced, adding the command used for this map as a remark at the end. Replace my two sample lines by your own.

To produce a map, run a command such as:

go

MapW 20 GroundTruth_Wicklow52.8 -6.65 53.4 -6.0511145670

where the parameters, always in this order, are:

MapW subdirectory (of the GroundTruth directory) for this map
20 family code for this map
GroundTruth_Wicklow name for this map in MapSource and the registry
52.8 -6.65 53.4 -6.05 bounding box (lat/lon bottom left and top right)
11145670 file name for first map file

The subdirectory will be created for you – it need not already exist. But if it does exist then files therein will be replaced by new versions. The family code is a small integer. Regard 1 and 338 as reserved for the Garmin built-in mapping, and start with 2, then use 3, 4, etc. (If you have bought any additional mapping already you will also need to regard the family code(s) for that mapping as reserved. Contact me for advice if needed on how to find the family code(s)) – there is software available, or check the registry, as shown below. Your map names need not be as verbose as my GroundTruth_Wickow – Wicklow would be fine, but I overkill here my adding a reminder that this is a GroundTruth map. Finally, a single rectangle may generate more than one map file, and by default a single map file will be named 12345678.img (the file name must be a number) and additional map files will be named by adding one each time to the first file name. If all maps are named in this default manner, the conflicting file names will cause data loss when multiple maps are uploaded to the device. 11145670 is a unique starting number supplied for use instead of 12345678 for this map.

A ninth, optional, parameter may also be needed, the “-nosea” shown above in the Mournes example. This may be needed where the map rectangle contains an area of water which is not fully included in that rectangle. Without this parameter the sea area off the coast “floods” inland and covers part of the inland area. When “-nosea” is added the sea “retreats” back to where it should be.

You will find other parameters in the manual, but most of these are unlikely to be needed. If you do find a need for a single one of these parameters but do not need the “-nosea” parameter, this can replace “-nosea” as the ninth parameter. In the very unlikely event of needing more than one of these additional parameters, or if you need an additional parameter but also need “-nosea”, the simplest solution is probably to create a new command file with these parameters included explicitly rather than supplied at run time via the replaceable parameters %1, %2, …, %9.

If however you are using Linux or Mac there is one parameter needed, the “-nonwin” parameter, which is best added permanently to your command script in this case, rather than added as that ninth optional parameter, thus leaving the ninth parameter available for use if needed.

There are two more points to consider with regard to the map rectangle. When contour data is included, this is downloaded as “tiles”, and in some cases these may not be sufficient to cover the rectangle of map data. If this is the case, simply enlarge the rectangle and try again until you find a rectangle where the contours now cover the original rectangle of interest, and accept that you will have some surplus map data as a result. You should also bear in mind that a large map rectangle will lead to slow screen redraws at any zoom level where a large area is shown. You can use a number of small map rectangles instead for faster screen redraws (these may overlap – if necessary you can even deselect individual map sections on the GPS itself).

At this point you should have a map ready to install to MapSource. Add the map produced to the set of maps installed for Garmin MapSource Trip & Waypoint Manager or Garmin MapSource, whichever was included with your Garmin GPS. To do this, look for a file 1_add.reg in the map subdirectory. This file contains the registry entries needed to install your map. Run it at the command prompt to add your map (you may for security reasons need to confirm that you really do want to modify the registry – the warning of imminent disaster which may accompany this request for confirmation should not worry you unduly unless you have foolishly chosen a reserved value for the family code, and even that would be only a minor disaster, easily remedied by reinstalling the Garmin MapSource application or additional mapping). The generated 1_add.reg file will look like the first version below, appropriate for 32-bit Windows. If you have a 64-bit Windows installation you should edit this to look like the second version (any line shown indented below is actually a continuation of the previous line). Your version will differ if you have installed GroundTruth in a directory other than “C:Program Files (x86)GroundTruth-1.8.740.17” (single backslashes in the file path are doubled in a reg file). You should also note that the family code for our example (20) appears in the reg file as hex:14,0. Hexadecimal 14 is the equivalent of decimal 20. Until you exceed 9 the entries will be hex:02,0 hex:03,0 … hex:09,0. The last part will remain “,0” until you reach 256, by which time you will have produced a lot of maps and should be quite familiar with hexadecimal numbers even if the concept was new to you at the start!

32-bit Windows:

REGEDIT4 
 
[HKEY_LOCAL_MACHINESOFTWAREGarminMapSourceFamilies

GroundTruth_Wicklow

] 
"ID"=

hex:14,0

 
"TYP"="C:Program Files (x86)GroundTruth-1.8.740.17

MapW

1.TYP" 
 
[HKEY_LOCAL_MACHINESOFTWAREGarminMapSourceFamilies

GroundTruth_Wicklow

1] 
"LOC"="C:Program Files (x86)GroundTruth-1.8.740.17

MapW”

 
"BMAP"="C:Program Files (x86)GroundTruth-1.8.740.17

MapW

1.img" 
"TDB"="C:Program Files (x86)GroundTruth-1.8.740.17

MapW

1.tdb"

64-bit Windows:

REGEDIT4 
 
[HKEY_LOCAL_MACHINESOFTWARE

Wow6432Node

GarminMapsourceFamilies 

GroundTruth_Wicklow

] 
"TYP"="C:Program Files (x86)GroundTruth-1.8.740.17

MapW

1.TYP" 
"ID"=

hex:14,00

 
 
[HKEY_LOCAL_MACHINESOFTWARE

Wow6432Node

GarminMapsourceFamilies 

GroundTruth_Wicklow

1] 
"BMAP"="C:Program Files (x86)GroundTruth-1.8.740.17

MapW

1.img" 
"LOC"="C:Program Files (x86)GroundTruth-1.8.740.17

MapW

" 
"TDB"="C:Program Files (x86)GroundTruth-1.8.740.17

MapW

1.tdb"

In the unlikely event that you have somehow managed to make a mess of one of the steps in the process, and added a generated map to the MapSource product which prevents that MapSource product starting, GroundTruth also generates a 1_delete.reg file which you can use to uninstall that map (for 64-bit Windows, edit as below to add Wow6432Node in the appropriate line.

32-bit Windows:

REGEDIT4 
 
[-HKEY_LOCAL_MACHINESOFTWAREGarminMapSourceFamilies

GroundTruth_Wicklow

]

64-bit Windows:

REGEDIT4 
 
[-HKEY_LOCAL_MACHINESOFTWARE

Wow6432Node

GarminMapSourceFamilies 

GroundTruth_Wicklow

]

Now use the Garmin software to upload maps to your GPS. Choose a map from the drop-down list.

Note that contours are often not visible in MapSource at higher zoom levels, as here, (or partly visible, as in the image included in the newsletter version of this article, reproduced below since it was cropped in the newsletter) …

… but the contours do appear when uploaded to the GPS. You will also need to make sure that “Map” is selected on the “Tools” menu:

Next, select the sections of the map (corresponding to individual files generated) which should be uploaded to the GPS. These take a light pink shading when selected. Note that there may also be a single file …

… covering the whole area, which should be selected even where only some of the smaller rectangles within are selected. Data to be uploaded to the GPS can come from more than one GroundTruth map. Simply choose another map from the drop-down list and select the desired sections of that map as well. Finally, select “Send To Device” from the “Transfer” menu, and send.

If you are comfortable using the Registry Editor you can verify the registry entries for the maps you add, or check the family codes (named here as “ID”) for maps already added to ensure that you do not select a conflicting code when adding a new map. Remember that these values appear in the registry as hexadecimal values. “14 00” below is 0014 (hexadecimal) or 20 (decimal).

Getting the latest OpenStreetMap data

When I referred earlier to adding missing features by using waymarks I mentioned “latest data”. The data downloaded using the command file described above lags behind the latest map data available at the OpenStreetMap website. There is however a certain logic behind this apparently stupid decision to use older data. There is an “Export” option on the OpenStreetMaps website which can be used to download the latest map data. But the area which can be downloaded at any one time is limited. This may be fine for a trip abroad to a similarly limited area, but may not be fine for example if you finish up with multiple overlapping map files to cover a larger area such as Wicklow, which could not be downloaded as a single data file from the website. In theory the command file could be changed to make its bulk data download from the latest data at the OpenStreetMaps website, and I have occasionally succeeded in doing so. But in practice this operation will virtually always timeout before the full data has been downloaded, usually in fact before any data whatsoever has been downloaded. So, at least to get started, I would suggest accepting the fact that the data you download from the alternative server which almost always provides a bulk data download without timing out may have some of the latest map data missing.

To see what this might mean in practice I have repeated the map screenshots shown earlier, but now using the latest data, and in addition modifying the default GroundTruth hiking map rules to include some data in the map which would otherwise be omitted using the default rules.

In the Turlough Hill map the reservoir now appears filled with blue, as the rules needed to be modified to treat an area described as “landuse|reservoir” in the same way as an area described as “natural|water”. In the middle screenshot the small lake is now included in the latest data, and the vegetation at the bottom right is treated now differently. In the screenshot on the right vegetation is now shown which was missing earlier, here again as a result of a couple of changes to the default GroundTruth hiking map rules (the lines shown as indented should be entered as continuations of the previous lines) to avoid loss of such data.

New:  | {{tag|landuse|forest}} or {{tag|natural|wood}} or {{tag|landuse|grass}} 
          or {{tag|natural|grassland}} 
Old:  | {{tag|landuse|forest}} or {{tag|natural|wood}} 
 
New:  | {{tag|waterway|riverbank}} or {{tag|waterway|river}} 
          or {{tag|natural|water}} or {{tag|landuse|reservoir}} 
Old:  | {{tag|waterway|riverbank}} or {{tag|waterway|river}} 
          or {{tag|natural|water}} 
 
Old:  | GuestHouse || {{tag|tourism|guest_house}} || 22 || || Bed & Breakfast inn 
          || name 
New:  | AlpineHut || {{tag|tourism|alpine_hut}} || 22 || || Alpine Hut || name

Try the process for yourself. Post any questions you may have on the IMC Forum, and I’ll try to answer.

Peter O’Neill