|The end result: a cycle map in Basecamp|
I don't think I've written a plug for OpenStreetMap (OSM) on this blog yet, but in case you didn't know: OSM is an awesome project, and I'm a regular contributor to and user of their database.
In preparation for my ride to Toronto I wanted to create a bike map to put on my Garmin GPS. For many regions in Europe pre-made cycling maps for Garmin are available but you have to DIY. I had created a OSM-based cycling map before but it only covered an area of 200km around Montreal. Creating that map had not been without problems, and unfortunately in the meantime I forgot a lot of the steps necessary. Consequently, this time I'm going to document the process for myself and others. I've tried to keep the instructions as dummy-friendly as possible, not requiring any deep understanding of the processes and programs involved. Feel free to ask questions in the comments and I'll try to answer them.
Before we get started, I should send out props to OSM-contributor and bike tourer Henning Scholland/aighes. If you live in Europe you don't have to create your owns maps but just download the ones he created. He has also been very helpful in guiding me through the process of generating my first map. Now let's make a map.
Step 1: Download dataFirst you have to download the data of the desired region. In the ideal case somebody will already have prepared an extract for that region. If that's the case you can move to step 3. In Canada, however, it is tricky: on the one hand, you probably won't want a map of all Canada (I heard Canada is big and cycling in the Northern Territories is kinda lonesome); on the other hand you probably want to include some parts of the US. In order to achieve that you will have to create your own extract, either from the "planet," i.e. the entirety of all OSM data, or from the North America extract which has a more manageable download size of about 5GB.
Step 2: Determine the bounding box and extract dataOnce you have downloaded the several gigabytes of data you will use the tool osmosis to extract the chunk of data that you want. That chunk is called the "bounding box", and it is basically a rectangle, defined by the coordinates of its four corners.
Install and run Osmosis: Download Osmosis and extract it into a folder. Open the command line and navigate to that folder. Run Osmosis as follows:
osmosis --read-pbf file="c:\Users\Harald\Downloads\america_north.osm.pbf" --bounding-box left=-81.0131836 top=47.2195681 right=-69.8730469 bottom=42.5368920 cascadingRelations --write-pbf file=Northeast.osm
read-pbfoption tells osmosis what kind of input file it is dealing with. The
fileparameter is the map data file you downloaded in step 1. The easiest way for entering the correct
bounding boxvalues is by using the export function on the openstreetmap.org slippy map: zoom to the desired area, click "Export," and copy the four coordinates you need (if you don't have quite the bounding box you want you can click "Select area manually" and then draw a rectangle). What
cascadingRelationsdoes I don't really know but it's probably good to include it.
write-xmldetermines the output format and shouldn't be changed. The final
filethen determines where to the output will be written.
Extracting the bounding box for a large region can take a while and create big files (in my case it was 8GB for an area of 520 by 880 km).
Step 3: Split the tilesFor reasons that don't need to concern you the bounding box extract will now have to be split up into tiles before the actual map making begins. For that download the tool splitter and extract it to a folder. Install and run splitter with the following parameters:
C:\Users\Harald\Desktop\splitter-r200\java -Xmx1500m -jar splitter.jar c:\Users\Harald\Desktop\osmosis-0.40.1\bin\Northeast.osm
Depending on how big your extract is and how much memory your machine has you will have to adjust the memory allocation with the
Xmxparameter. Stated simply: you want to allocate as much memory as possible. If you try to allocate too much you'll get an error message and can adjust the value down. My system has 4GB RAM and I couldn't assign 2000M but 1500M worked. If you don't have enough memory assigned the splitting process will fail. Once again, the splitting will take a while (in my case about 10 minutes). The end result will be a whole bunch of .pbf files, a file called template.args, and one file called areas.list.
Step 4: Download boundariesIn order to have a functioning address search on your Garmin, you will need to integrate administrative boundaries while making the map (i.e. the boundaries of countries, states/provinces, municipalities). Download the file from here and unzip into the same directory as your tiles. (Please note that searching for addresses doesn't work all that well in Canada because of a lack of boundary data.)
Step 5: Download map styleIf you want to use the style of the aighes's RadReiseKarte (bike touring map), download
style.zipfrom his homepage and extract the contents of the
datadirectory into the folder containing your map data. You should now install mkgmap. After the installation you can do a quick test of the style file: run mkgmap as follows (depending on where you put your files you have to modify the path to the style folder):
java -jar mkgmap.jar --style-file=data/style_rrk -- list-styles
This should produce an output of
The following styles are available:
style_rrk 1: No summary available
Step 6: Create the map with mkgmapNow run the following, very long command from the directory containing your map data and the style directory:
java -Xmx1500m -jar mkgmap.jar --max-jobs=4 --read-config=data\style_rrk\options --code-page=1252 --mapname=66000000 --overview-mapname=66000000 --family-name="Cyclemap Northeast" --series-name="Cyclemap Northeast April 2012" --description="Cyclemap April 2012" --family-id=6600 --output-dir=maps\
Unless you know what you're doing (I certainly didn't when I was doing this myself) I don't recommend changing anything except for the series name and family name parameters and the path to the desired output directory. Once again, you'll have to wait a while until mkgmap finishes.
Step 7: Install map into Mapsource/BasecampMkgmap can create IMG files which you can copy directly onto your Garmin device. In general, however, it's easier to install the map in Mapsource/Basecamp first. This requires you to download the NSIS installation system. Start the program, select the output-dir defined in the previous step, and voila: you have an installer for your new map.
This is what the map will look like in Basecamp at a higher zoom level (I couldn't get a good pic of the map on my Garmin Etrex).