2011-09-17: Dear OpenStreetMappers it has been a while ago that I wrote the documentation you'll find on this page. There are some changes in the JOSM software and the required stylesheets. Please find in this ZIP file osmarender.zip a collection of all the tools that you need to run the examples below.

To use new tools, please put the ZIP file in the 'openstreetmap' directory you'll create in the examples below. Then unpack the ZIP file with the command:
unzip osmarender.zip
Now you have all the tools you need to create your maps. Good luck!

Patrick

Create Your Own Maps Using OpenStreetMap

Introduction

Hi, in this tutorial I'll show you how to create your own maps using OpenStreetMap. These are the requirements needed to repeat the examples given below:

Install JOSM

JOSM, stands for Java OpenStreetMap editor, is a tool to download and edit maps created by the OpenStreetMap community. In this section I'm going to show you how to install and run the JOSM editor.

First you need to go to the JOSM download site (http://josm.openstreetmap.de/) and get the latest version. At the bottom of the page you'll find the 'download' link. Save the 'josm-latest.jar' file on your desktop for now.

To install the software you need to open a terminal window (hint: cmd-space + type 'terminal').


Fig. 1 A terminal window

From now on we will type commands in this terminal window. Create a new directory by typing the command:

	mkdir openstreetmap

Fig. 2 Creating a directory using the terminal

Change your working directory to this new directory with the command:

	cd openstreetmap

Install the JOSM into this directory with the command:

	cp ~/Desktop/josm-latest.jar .
[which stands for: copy the josm-lastest.jar file from your Desktop to the current directory]

Let's check if everything worked fine by running the JOSM editor with this command:

	java -jar josm-latest.jar

Fig 3. All installation commands

If everything is okay, you should have the JOSM editor application now running.


Fig 4. JOSM editor

QUIZ

Question:What steps do you need to follow to start the installed JOSM editor the next time?

Answer: Open a terminal window (cmd-space + 'terminal'). Type: 'cd openstreetmap'. Type: 'java -jar josm-latest.jar'.

Download a MAP

Congratulations, you've installed JOSM now it's time to download some data by fetching map. To do this go to the OpenStreemMap website (http://www.openstreetmap.org/). Search for your favorite city e.g. 'Copenhagen'. Click first on a search result and then on the 'view' tab on the top of the webpage. You need to click 'view' to see the exact URL or HTTP address in you browser location bar.


Fig 4. Searched for 'Copenhagen', clicked the search result and clicked the 'View' tab to get the correct URL in the location bar.

Do you see the URL http://www.openstreetmap.org/?lat=55.68&lon=12.569&zoom=10&layers=B00FTF in the location bar? This URL you will use to download data into the JOSM application.
Now, copy this URL with cmd-c and go to your JOSM application. Open 'File->Download from OSM...':


Fig 5. Open JOSM download window


And paste with ctrl-v the URL in the textarea on the bottom:

Fig 6. Paste the URL in the download text area


You'll see that JOSM automatically fills in all the other fields. Click on 'OK' to download the map data. This may take a while. You may increase or decrease the download data by altering the zoom level in the URL or in the webpage before you hit the 'view' tab. But be aware, the OSM servers have a maximum download size they are willing to serve.

The end result of should be a window containing a vectorial view of your map:

Fig 7. Downloaded map


This doesn't look like a real map. Indeed, this is the view you need to alter a map. All the lines can be streets or waterways, dot can be a landmark, etc. Everything can be changed, edited, deleted. But, this is not what we are going to do in this tutorial. JOSM will only be used to download data from the OpenStreemMap servers. The only important thing we need to do in this interface is to save the map into a file named 'data.osm'. The filename is important, all other tools in this tutorial require this file name. Save the map in JOSM with the menu 'File->Save as' save the file in the 'openstreetmap' directory with name 'data.osm'.

Fig 6. Save the map

QUIZ

Question:What steps do you need to follow to download a new map?

Answer: Go with your web browser to http://www.openstreetmap.org, search a city, click on a search result, click on the 'View' tab, copy the web address in the location bar with cmd-v, go to JOSM, File->Download from OSM, paste the address with ctrl-v, press ok, save the map as 'data.osm' in the 'openstreetmap' directory.

Render a MAP

To transform the vectorial view of the map into something more artistic is called rendering. We need to process the data.osm file with some tools and calculate all colors, images, streets, waterways we need to put on the map. This is a very resource intensive process, your computer can become quite slow and can require several minutes (or in some case 1/2 to 1 hour) of processing time.

The tool we are going to use is called 'osmarender' and can be downloaded from the Internet. You need to download two files and save them into the 'openstreetmap' directory:

The first file is a features file which tells the osmarender what you want to put on the map. The second file is a stylesheet that directs the actual rendering work. This means, you may need to edit the first file to add or delete features, but you don't touch the second file.

For now we don't touch anything. Let's try to render our 'data.osm' file. Open a terminal (hint: cmd-space + 'terminal'). And go to the 'openstreetmap' directory (hint: 'cd openstreetmap'). Now, run the following command:

	xsltproc osm-map-features-z17.xml > copenhagen.svg
(which means: start some rendering process with help of the feature map and save the results in the file copenhagen.svg). You will get a lot of messages on the screen and after a while (on my laptop about 5-6 minutes) the render process should be finished.

Fig 7. After 5-6 minutes and a lot of output messages the redering process finishes. Notice the 'ls -lrt' command used to view which files were created.

To view the map programs like 'Inkscape' can be used. Be aware that the resulting maps are quite large. It takes therefor quite some processing power to open the resulting copenhagen.svg file in Inkscape. On my laptop it takes about 1-2 minutes and results into quite slow response times. This you have to live with, these maps are very big, you need quite a bit of RAM to handle them.


Fig 8. The copenhagen.svg file can be viewed in the Inkscape application

To export these files to programs like Adobe Illustrator, EPS files need to be created. This can be done using the Inkscape graphical interface (File->Save As->copenhagen.eps), but at the time of writing this couldn't be done on very large maps due to a bug in one of the underlying system tools. What you need is the Inkscape command line tools. They require less RAM and gives you a better ability to process very large files. To create an EPS file from a SVG file use this command in your terminal window:

	/Applications/Inkscape.app/Contents/Resources/bin/inkscape -E copenhagen.eps copenhagen.svg 
Here copenhagen.svg is the result of the render process above, and copenhagen.eps is the file you want to create. On my laptop it takes about 2-3 minutes to do the conversion. When rendering and converting files you need to close as many applications as possible, because you'll need all the system resources you can get.

Fig 9. Conversion of SVG into EPS using the Inkscape command line tool

QUIZ

Question: What steps do you need to render a EPS map?

Answer: open a terminal, go into the 'openstreetmap' directory, run the command 'xsltproc osm-map-features-z17.xml > copenhagen.svg', when finished, run the command '/Applications/Inkscape.app/Contents/Resources/bin/inkscape -E copenhagen.eps copenhagen.svg'.

Adding/Deleting features

The end result of the render and conversion process may not be what you really want. You may want the map to look a bit different from the results you get. In this section I'm going to explain some of the rendering features you can change quite easily. This subject is very extensive, this section given only an introduction.

To change the features of a rendered map you need to edit the ...features file, indeed. For this we'll use the TextMate editor. Go to you terminal window and type:

		mate osm-map-features-z17.xml
	
You'll see the following XML file:

Fig 10. The feature file opened in TextMate


Don't be alarmed by the XML syntax. It is quite straightforward to read and edit. E.g. do you see the 'scale="1"' parameter on the 12th line from to top? With this parameter you can change the level of detail in the map. E.g. Save you changed with the keys cmd-s. To be very sure that the XML file isn't broken by your changes you need to run the command:
	xmlwf osm-map-features-z17.xml
If you don't see any error messages, them everything is fine. With the new feature file you can rerender and convert the map. If you don't remember the steps, then look at the quiz of the previous section.

Deleting features is also possible. E.g. you don't like the parking icons on the map and want them removed. Open again the feture file with 'mate osm-map-features-z17.xml', and search for 'parking' in the file (hint: cmd-f + 'parking' enter). You will see a rule like:


Fig 11. This rule in the features file will cause parkings to be displayed on the map.


If you delete this rule (all the text from: <rule> untill </rule>) and save the file, then the icons for parkings will disappear from the map. As always, when you change the feature file run the command xmlwf osm-map-features-z17.xml to check if you haven't made any mistakes.

Using the technique above you can delete many features. You have to remember you need always to delete features from <rule> untill </rule>.


(c)2008 Patrick Hochstenbach <patrick.hochstenbach at gmail.com>