Enrich OSM maps with additional information

Custom Print

Article from Issue 192/2016
Author(s):

Maperitive helps users create high-quality maps with additional information from OpenStreetMap data.

The word has spread that OpenStreetMap (OSM) offers high-quality data for many areas. Even established GPS manufacturers are now using this data source – at least for outdoor devices, where users require minute detail. This makes using the data provided by the OSM project for your own maps all the more desirable. Currently, only printed maps display sufficiently large areas at a high resolution with enough details for planning trips.

Another benefit is that you can modify the OpenStreetMap data yourself. If you need a specific cycling route or want to see the picnic areas on the maps, for example, you have two options. First, you can add the information directly to your project with the online editor or with programs like Merkaartor [1], Josm, or others. Second, tools such as Maperitive [2] let you generate maps in high resolution as image files, which you can then edit with Gimp or Inkscape.

The first method – that is, editing the OSM data – is preferred because it benefits the entire project. However, for very specific tasks, the second method is better and faster because you do not need to wait for the data to update on the server. On the other hand, you do need to re-enter your own changes each time you reload the database.

In many online publications, you will find OSM maps as screenshots, but this is only useful for ebooks. For printed publications, the resolution (typically under 100 dpi) of the images provided in the browser is too low to ensure legible results. The classic way of producing better quality images is via a separate Mapnik server, but this causes significant overhead in terms of the installation and operation.

Tools such as Maperitive enter the scene here: They generate bitmap (tiles) or SVG maps directly from the OSM data, giving you extensive control over the content.

Geodata

Maperitive reads and interprets the geodetic data and computes the maps. You can customize the data loaded from various sources [3] using styles and save the results in different formats. Several predefined styles exist for the basic types of maps; these styles are available immediately after installation. If necessary, you can customize them to produce personalized maps.

As a Mono application, Maperitive can be used across platforms, but the installation is typically a manual process (see the "Installation" box). The program makes heavy use of resources, especially CPU time and memory, for working with large maps.

Installation

Maperitive is not found in the repositories of popular distributions. Despite its dependence on Mono, the installation is quite simple: First, install the Mono framework – the package name varies between distributions. In addition, Maperitive needs libgdiplus version 3.8 and Python. On Ubuntu, you can then retroactively install the libmono-winforms2.0-cil and mono-devel packages if necessary. Then, unzip the zip archive containing the current version of Maperitive, preferably in /opt/. Next, start the Maperitive script Maperitive.sh. If you move the script to /usr/local/bin/, you will need to modify the path to Maperitive.exe.

Launch

After launching, Maperitive comes up with a simple interface (Figure 1). The menu at the top of the window provides basic functions; the image section offers a preview of the map. The Commander at the bottom left lets you enter special commands; the Map Sources to the right provides an overview of the data source and lets you select a source. The status line at the bottom of the window shows the current Zoom level, as well as the current memory consumption, among other things.

Figure 1: Maperitive launches into a classical OSM (web) map.

Only a few of the functions and commands offered by Maperitive are reflected in the menu. The Commander, a shell-style interface, provides full access to all functions. Here you can define all the details of the functions, using command arguments and parameters.

In the image window, you can select the visible section with the mouse. To do this, you typically need to click on the section, because the Commander is normally active. In the selected image window, you can change the section (Zoom level) using the mouse wheel. If you hold down the Shift key, you can select areas of the preview and zoom them to full screen.

When launched, the program shows you the OSM map from the web referred to in the sources as Web map (OSM Mapnik) by default. This map uses prefabricated bitmap tiles provided by a Mapnik server whose appearance you can change with Maperitive. Because you will normally be using the software to create your own maps or test your own rules, you will likely want to disable or remove this source. To do this, select the unwanted source and press the button with the cross above the window.

Interaction with the program is mainly via the Commander window. It consists of an area for the output (top) and an input line (Commander prompt). The output is also used as the log window and displays the responses to the executed commands. At the prompt, you then enter commands with arguments and run them (Table 1). The command line has a history and an auto-complete function to make working with the program more convenient.

Table 1

Important Commands

Command

Function

add-web-map

Add web presentation

apply-ruleset

Apply rule set

change-dir

Change working directory

clear-map

Remove map sources

clear-results

Delete results of a search

download-osm

Read OSM data for the current bounding box (standard method XAPI)

download-osm-overpass

Read OSM data for the current bounding box from the Overpass Server

edit-rules

Open the rule set editor

export bitmap

Export map as bitmap graphic

export-svg

Export map as SVG graphic

export-osm

Export map as OSM file (XML)

help

Show help

list-settings

Show settings

list-sources

View sources

load-source

Download OSM, GPX, or bitmap graphic

reload-ruleset

Reapply the current rules

run-script <script>

Run Maperitive script

save-map-script

Save commands as script

set-home

Remember display

set-setting

Configure settings

use-ruleset

Load a set of rules

use-script-dir

Change script directory

zoom-map-scale

Zoom map according to scale

The command line collaborates directly with the wizard (Figure 2). You can enable the wizard in the Window menu by selecting Wizard or pressing F1. It acts as an online help on the one hand, explaining the commands and their arguments. On the other hand, it inserts a command and its arguments in the command line if you double click.

Figure 2: The wizard has two functions: It explains the commands and lets you transfer them to the command line with a double click. There is no need to specify all the arguments for the commands.

To quickly view the loaded data, the program has a couple of pre-built rule sets. You will find these styles in the Map menu below Switch to rules. After calling this function, the software computes a new view of the map, which can take some time.

Practice

The following descriptions essentially refer to a project that was created for a forthcoming ebook. However, the procedure is suitable in many parts for other projects. For this workshop, I used Maperitive version 2.3.35. The following steps create a new map:

  • Download the map data.
  • Create an initial overview.
  • Define what the map shows (create rules).
  • Test, adapt, and improve the rules.
  • Install the finishing touches, such as contour lines.
  • Create an output file (SVG file).
  • Finishing: Edit and print the SVG file.

The data for the maps come from two sources: either directly from the OSM servers or from prefabricated OSM files. The current version of Maperitive can directly download the OSM data and even save it locally. The benefit of using locally stored maps should not be underestimated: Although the online data constantly changes, you can evaluate and adjust local records as needed. However, not all OSM file formats are suitable for all editors – Merkaartor does not read PBF files.

To load the online data, first move and scale the map so that it shows the desired area. In the Map menu, select Set Geometry Bounds, the function for defining the limits. To do so, shrink the section slightly until the software shows the boundaries of the area in the preview. Handles let you precisely set the desired section in the corners. In densely mapped areas, it is well worth precisely choosing the section you need; this saves disk space and computing time later.

Next, select Download OSM data (Overpass) to start the download. Depending on the location and size of the area, this can take a while. Load the generated files into the program via File | Open map sources… . To test the data for correctness and completeness, you can just apply the standard rules via Switch to rules in the Map menu. To do so, disable the Web map below Map sources to see the results.

The next step is the most complicated: You need to create or modify the rules to make individual adjustments. In the Map menu, Edit rendering rules launches an editor with the currently active rules. Basically, you have two ways to proceed here. You can edit the pre-built rules, which can often be quite complex and difficult to understand. A tip for doing this: First, look at the files below ./rules/ in the Maperitive installation directory, instead of just editing the default rules. Alternatively, you can gradually build up your own rule set. If you need inspiration, you can look at some existing rules [4].

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Digitizing Analog Music Media

    Armed with the Audacity sound editor, you can convert the analog content of LPs, tapes, and cassettes to the digital world.

  • FileZilla

    High-performance GUI-based ftp clients for Linux are hard to find. The graphical FileZilla ftp client closes the gap.

  • KTools: Treeline

    Mindmaps are useful for organizing ideas and data. Treeline is a promising mindmap tool for KDE.

  • Labyrinth

    The Labyrinth mind mapper lets you collect and organize your thoughts and ideas without major detours.

  • Command Line: Using udev

    Learn how to create your own udev rules and deploy command-line tools to monitor and control udev events to clear your way through the Linux device jungle.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News