Showing posts with label maps. Show all posts
Showing posts with label maps. Show all posts

Friday, March 28, 2014

“First insure your bicycle, then study the map” – 1897 Montreal Bike Map

I just came across this awesome 1897 bike map of Montreal on reddit. Back then, Montreal had not yet encountered the automobile -- only in November 1899 did Ucal-Henri Dandurand drive the first car in Montreal. As you can see on the upper left of the map, the dotted lines represent "good roads," whereas the solid red lines are just "roads." It would be fun to do an overlay of the present-day bike network and the cycling roads of 1897...


Source: BANQ

Thursday, May 3, 2012

Creating a bike map for Garmin devices based on OSM data

The end result: a cycle map in Basecamp
Update September 2012: A while ago, Henning suggested minor modifications to the commands in steps 2 and 6 that should improve performance.

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 data

First 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 data

Once 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

The read-pbf option tells osmosis what kind of input file it is dealing with. The file parameter is the map data file you downloaded in step 1. The easiest way for entering the correct  bounding box values 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 cascadingRelations does I don't really know but it's probably good to include it. write-xml determines the output format and shouldn't be changed. The final file then 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 tiles

For 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 Xmx parameter. 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 boundaries

In 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 style

If you want to use the style of the aighes's RadReiseKarte (bike touring map), download style.zip from his homepage and extract the contents of the data directory 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 mkgmap

Now 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/Basecamp

Mkgmap 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).