Thursday, December 19, 2013

Garmin and OpenStreetMap

I've got a handheld GPS from Garmin - the eTrex Vista HCx, which I bought in anticipation of a trip that didn't happen, and haven't had any real reason to use it until now.

Now, I'm headed to Myanmar and could use some GPS to guide my bike adventures. Trouble is, garmin would like me to pay a lot for some pretty useless and out of date maps. Luckily, openstreetmap has come a long way and is now looking pretty good, even for Myanmar. So here, I've just figured out the rather tricky process of getting maps onto the device and getting them recognized.

Get a usable map with the information you need for the region you'll be in. The easiest option is to download something somebody else created. Have a look here, and particularly here, although the latter appears to need a >=4GB microSD card (mine is 1GB). Unfortunately none of the pre-made maps cover Myanmar, at least not in enough detail for me.

1) Download the area of OSM you need using the API. I did the following to download.
wget -O myanmar.osm http://www.overpass-api.de/api/xapi?map?bbox=93.4,15.5,98.0,23.0
This bounding box covers most parts of Myanmar that tourists are allowed to visit.
2) Next, convert it to the format needed by Garmin. For this, use mkgmap which is a java command line program available from here. For my purposes, it was necessary to provide a custom style file which specifies what features go into the garmin map and how they look. I used the cyclemap style explained here, and downloaded cyclemap.TYP to the same directory:
svn co http://svn.openstreetmap.org/applications/utils/export/garmincyclemap/network/cyclemap
3) I unzipped the mkgmap files to another subdirectory in the same location.
4) I used the cyclemap styles unmodified, although they could have been improved for my uses (they're designed for the UK). Then I simply ran:
java -jar mkgmap-r2889/mkgmap.jar --style-file=cyclemap --remove-short-arcs --style-file=cyclemap --route --net --mapname=Myanmar --description=Myanmar --gmapsupp myanmar.osm

This produced gmapsupp.img, which is the garmin-format map file I needed. (I had no need to split the osm or ask java for extra memory, but more info here.)

The next step is getting this onto the device. In theory, the easiest option should be to simply copy this file to the Garmin\ subdirectory on the microSD card using a card reader. But in my experience, the garmin device never recognized it. That leaves two other options.

1) In windows, install the Garmin USB drivers (first!). Then connect and turn on the Garming GPS using the USB cable. Under Menu->Setup->Interface and select USB Mass Storage. This will show the SD card as a drive on the computer. Copy the gmapsupp.img file to the Garmin\ directory on the device. (Note there can only be one custom map file on the device at a time and it must be in this location/filename). Eject it and power down the device.
2) Use sendfile to copy the file onto the device (this should work in linux or windows; in windows it also requires the Garmin USB drivers). After completing, eject the device and power it down.

Finally, disconnect the GPS from the computer and power on. There should be mention of OPENSTREETMAP copyrights during bootup. To confirm that the map is there, you can go to Menu->Setup->Map and scroll right to the info icon, where you should see your map selected. You should also be able to zoom out and pan to the coverage area (if you're already within the coverage area, no need to pan!). Note that it may only really be visible at certain zoom levels. You could also "Find" a city, say, or other place in your new map.

Enjoy!

No comments:

Post a Comment