Generating scalable maps with OSM and SUMO
Abstract: A short demonstration of generating scalable maps using OpenStreetMap data and SUMO for visualisation.
Topics: applications/SUMO, visualisation/maps, opengl
© Copyright Daniel Krajzewicz, 23.02.2019 21:00, cc by
Introduction
You may need some scalable maps for some reason. Here's how to generate ones using data from the OpenStreetMap project and SUMO for visualisation. Scalable means herein that the maps are stored as .pdf-files into which you can zoom. Other vector formats — Postscript (.ps), Encapsulated Postscript (.eps), or Scalable Vector Graphics (.svg) — are supported as well. And, you may as well export the map to a plain bitmap image file, such as .png, .gif, or .jpg.
Figure 1: Maps of a) the Tempelhof airfield in Berlin, Germany, b) the DLR site in Berlin, Germany; click for the .pdf-version.
The maps generated this way are free of charge. In the following, the steps steps for preparing scalable maps are presented, first. Then the resulting files are given. Possible extensions and closing thoughts are given afterwards.
Generating the Maps
The steps to perform for obtaining scalable maps are given below.
Installing SUMO
SUMO comes as binary releases for different operating systems (see SUMO downloads on SUMO-wiki), including MS Windows and major Linux distributions. Yet, to my knowledge, the common distribution does not contain the gl2ps module, which is responsible for exporting vector graphics. So probably, you have to compile SUMO by yourself. Instructions on building SUMO on Windows and on building SUMO on Linux are available. As said, assure that you include the gl2ps module.
Downloading an OSM map
OpenStreetMap (OSM) is a crowdsourced digital map. You may download an area of interest by navigating to it and then clicking on the “Export” button. You may as well use one of the named sources of maps which offer selected areas for download. You have to download the map in the OSM-format. And, you should start with a small area — it is easy to export a large map from OSM but you will see that it takes a lot of resources for building a SUMO-representation and that the visualisation will get slow when using really large maps, see also below.
Converting OSM for being usable in SUMO
Being a traffic flow simulation, SUMO deals mainly with road networks. Accordingly, the first step is to use the OSM-file to generate a road network. This is done using the command line application netconvert. The call for converting your map is quite simple:
...>netconvert --osm <OSM_FILE> -o <SUMO_NET> -v
Where <OSM_FILE> is the path to and the name of OSM file you have downloaded and <SUMO_NET> is the SUMO road network to generate. The network usually has the extension “.net.xml”. So a real call could look like this:
...>netconvert --osm berlin201810280052.osm -o berlin201810280052.net.xml -v
In addition, you should as well build a representation of all the other geometric information stored in OSM-files, like buildings, trees, etc. This can be done using the polyconvert tool. This tool needs a previously converted network to know the projection. The call is quite easy nonetheless:
...>polyconvert --osm berlin201810280052.osm -n berlin201810280052.net.xml -o berlin201810280052.poi.xml -v
As you may note, SUMO geometry files have the extension “.poi.xml”.
Loading the files into SUMO
The next step is to force SUMO to load the files you've generated. I use a configuration file which lets SUMO load the network and the geometries. Because both files were generated by native SUMO-tools, I set additionally the XML schema validation to “never” — the files should be all right. The configuration file looks like the following:
<c>
<n>berlin201810280052.net.xml</n>
<a>berlin201810280052.poi.xml</a>
<X>never</X>
</c>
You may now load the file into SUMO's graphical user interface “sumo-gui” using the menu “File->Load Configuration”.
Figure 2: SUMO-GUI after loading the representation of a) Berlin, Germany, and zoomed to b) the Tempelhof airfield, c) the DLR center at Adlershof
Exporting the Map
After loading, sumo-gui should show the obtained map. You can now zoom / move the view to the area you want to export. For exporting it as an image or as a scalable vector file, you have press the camera-icon. It's that easy.
Results
In the following table, you may find the example maps exported into different formats.
One may note, that already such small examples yield in big file sizes. So one should really start with small maps.
Format | Berlin Tempelhof (Link, size) | Berlin Adlershof (Link, size) |
---|---|---|
.gif | berlin_adlershof.gif (181kB) | berlin_adlershof.gif (235kB) |
.jpg | berlin_adlershof.jpg (410kB) | berlin_adlershof.jpg (456kB) |
berlin_adlershof.pdf (5689kB) | berlin_adlershof.pdf (20422kB) | |
.png | berlin_adlershof.png (265kB) | berlin_adlershof.png (364kB) |
.ps | berlin_adlershof.ps (7589kB) | berlin_adlershof.ps (28163kB) |
.svg | berlin_adlershof.svg (7589kB) | berlin_adlershof.svg (63002kB) |
Extensions
We have already loaded additional geometries into SUMO for having buildings, trees, etc. included. Now, it should be as well possible to, e.g., load an additional geometry that points to a certain location — a circle or an arrow. Yet, up to now, this has to be done manually.
Closing thoughts
Well, this is one possibility to generate scalable maps for free. I hope you liked it. If you have any comments, please let me know.
References
- SUMO is a microscopic traffic flow simulation developed by the DLR.
- OpenStreetMap is a crowd sourced digital map.
- gl2ps allows writing openGL-screens to vector formats.