Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible
Find a file
2021-08-26 01:12:04 +03:00
.github Add options to tile generation. 2021-08-25 23:56:49 +03:00
data/githooks Issue #63: add options for MapCSS generation. 2021-08-15 09:55:46 +03:00
doc Add JOSM style example. 2021-08-26 01:12:04 +03:00
icons Issue #53: add icon for amenity=bicycle_rental. 2021-07-26 23:47:08 +03:00
roentgen Add options to tile generation. 2021-08-25 23:56:49 +03:00
scheme Add options to tile generation. 2021-08-25 23:56:49 +03:00
test Add options to tile generation. 2021-08-25 23:56:49 +03:00
.gitattributes Remove PNG from .gitattributes. 2020-09-28 00:06:50 +03:00
.gitignore Update .gitignore. 2021-07-19 23:45:50 +03:00
LICENSE Add license. 2021-08-14 23:02:23 +03:00
README.md Add JOSM style example. 2021-08-26 01:12:04 +03:00
requirements.txt Upgrade Pillow due to security alert. 2021-08-21 23:36:44 +03:00
roentgen.py Refactor entry point. 2021-08-24 23:01:41 +03:00
setup.py Issue #18: add setup.py. 2021-08-25 02:00:22 +03:00

Röntgen (or Roentgen when ASCII is preferred) project consists of

The idea behind the Röntgen project is to show all the richness of the OpenStreetMap data: to have a possibility to display any map feature represented by OpenStreetMap data tags by means of colors, shapes, and icons. Röntgen is created for OpenStreetMap contributors: to display all changes one made on the map even if they are small, and for users: to dig down into the map and find every detail that was mapped.

Unlike standard OpenStreetMap layers, Röntgen is a playground for experiments where one can easily try to support proposed tags, tags with little or even single usage, deprecated tags.

Röntgen is intended to be highly configurable, so it can generate precise but messy maps for OSM contributors as well as pretty and clean maps for OSM users, can use slow algorithms for some experimental features.

Usage example

roentgen render -b 2.284,48.860,2.290,48.865

will automatically download OSM data and write output SVG map of the specified area to out/map.svg. See Map generation.

roentgen tile -b 2.361,48.871,2.368,48.875

will automatically download OSM data and write output PNG tiles that cover the specified area to out/tiles directory. See Tile generation.

Map features

Röntgen features:

  • detailed icons to display subtypes like power tower design,
  • can display multiple icons for one entity to cover more features,
  • use color to visualize colour and other features like plant types,
  • display primitive 3D shapes for buildings,
  • display directions with gradient sectors,
  • use width to display roads.

Isometric building shapes

Isometric shapes for walls and shade in proportion to building:levels, building:min_level, height and min_height values.

3D buildings

Trees

Visualization of tree leaf types (broadleaved or needleleaved) and genus or taxon by means of icon shapes and leaf cycles (deciduous or evergreen) by means of color.

Trees

Viewpoint and camera direction

Visualize direction tag for tourism=viewpoint and camera:direction for man_made=surveillance.

Surveillance

Power tower design

Visualize design values used with power=tower tag.

Power tower design

Power tower design

Emergency

Emergency

Japanese map symbols

There are special symbols appearing on Japanese maps.

Japanese map symbols

Icon set

The central feature of the project is Röntgen icon set. It is a set of monochrome 14 × 14 px pixel-aligned icons. Unlike the Röntgen source code, which is under MIT license, all icons are under CC BY license. So, with the appropriate credit icon set can be used outside the project. Some icons can be used as emoji symbols.

All icons tend to support common design style, which is heavily inspired by Maki, Osmic, and Temaki.

Icons are used to visualize tags for nodes and areas. Unlike other renderers, Röntgen can use more than one icon to visualize an entity and use colors to visualize colour value or other entity properties (like material or genus).

Icons

Feel free to request new icons via issues for whatever you want to see on the map. No matter how frequently the tag is used in OpenStreetMap since final goal is to cover all tags. However, common used tags have priority, other things being equal.

Generate icon grid and sets of individual icons with roentgen icons. It will create out/icon_grid.svg file, and SVG files in out/icons_by_id directory where files are named using shape identifiers (e.g. power_tower_portal_2_level.svg) and in icons_by_name directory where files are named using shape names (e.g. Röntgen portal two-level transmission tower.svg). Files from the last directory are used in OpenStreetMap wiki (e.g. File:Röntgen_portal_two-level_transmission_tower.svg).

Shape combination

Röntgen constructs icons from the shapes extracted from the sketch SVG file. Some icons consists of just one shape, to construct other it may be necessary to combine two or more shapes.

Bus stop icon combination

Wireframe view

Creation time mode

Visualize element creation time with --mode time.

Creation time mode

Author mode

Every way and node displayed with the random color picked for each author with --mode user-coloring.

Author mode

Installation

Requirements: Python 3.9.

To install all packages, run:

pip install -r requirements.txt
pip install .

Map generation

Command render is used to generates SVG map from OpenStreetMap data. You can run it using:

roentgen render \
    -b <min longitude>,<min latitude>,<max longitude>,<max latitude> \
    -o <output file name> \
    -s <osm zoom level> \
    <other arguments>

Example

roentgen render \
    --boundary-box 2.284,48.860,2.290,48.865 \
    --output out/esplanade_du_trocadéro.svg

will download OSM data to cache/2.284,48.860,2.290,48.865.osm and write output SVG map of the specified area to out/esplanade_du_trocadéro.svg.

Arguments

Option Description
-i, --input <path> input XML file name or names (if not specified, file will be downloaded using OpenStreetMap API)
-o, --output <path> output SVG file name, default value: out/map.svg
-b, --boundary-box <lon1>,<lat1>,<lon2>,<lat2> geo boundary box; if first value is negative, enclose the value with quotes and use space before -
--cache <path> path for temporary OSM files, default value: cache
--seed <string> seed for random

Tile generation

Command tile is used to generate PNG tiles for slippy maps. To use them, run Röntgen tile server.

Option Description
-c, --coordinates <latitude>,<longitude> coordinates of any location inside the tile
-t, --tile <scale>/<x>/<y> tile specification
--cache <path> path for temporary OSM files, default value: cache
-b, --boundary-box <lon1>,<lat1>,<lon2>,<lat2> construct the minimum amount of tiles that cover requested boundary box

Generate one tile

Specify tile coordinates:

roentgen tile --tile <OSM zoom level>/<x>/<y>

or specify any geographical coordinates inside a tile:

roentgen tile \
    --coordinates <latitude>,<longitude> \
    --scale <OSM zoom level>

Tile will be stored as SVG file out/tiles/tile_<zoom level>_<x>_<y>.svg and PNG file out/tiles/tile_<zoom level>_<x>_<y>.svg, where x and y are tile coordinates. --scale option will be ignored if it is used with --tile option.

Example:

roentgen tile -c 55.7510637,37.6270761 -s 18

will generate SVG file out/tiles/tile_18_158471_81953.svg and PNG file out/tiles/tile_18_158471_81953.png.

Generate a set of tiles

Specify boundary box to get the minimal set of tiles that covers the area:

roentgen tile \
    --boundary-box <min longitude>,<min latitude>,<max longitude>,<max latitude> \
    --scale <OSM zoom level>

Boundary box will be extended to the boundaries of the minimal tile set that covers the area, then it will be extended a bit more to avoid some artifacts on the edges rounded to 3 digits after the decimal point. Map with new boundary box coordinates will be written to the cache directory as SVG and PNG files. All tiles will be stored as SVG files out/tiles/tile_<zoom level>_<x>_<y>.svg and PNG files out/tiles/tile_<zoom level>_<x>_<y>.svg, where x and y are tile coordinates.

Example:

roentgen tile -b 2.361,48.871,2.368,48.875

will generate 36 PNG tiles at scale 18 from tile 18/132791/90164 all the way to 18/132796/90169 and two cached files cache/2.360,48.869,2.370,48.877_18.svg and cache/2.360,48.869,2.370,48.877_18.png.

Tile server

Command server is used to run tile server for slippy maps.

roentgen server

Stop server interrupting process with Ctrl + C.

MapCSS 0.2 generation

Command mapcss is used to generate MapCSS scheme. roentgen mapcss will create out/roentgen_mapcss directory with simple MapCSS 0.2 scheme adding icons from Röntgen icon set to nodes and areas: .mapcss file and directory with icons.

To create MapCSS with Röntgen style also for ways and relations, run roentgen mapcss --ways.

Option Description
--icons add icons for nodes and areas, set by default
--ways add style for ways and relations
--lifecycle add icons for lifecycle tags; be careful: this will increase the number of node and area selectors by 9 times, set by default

Use Röntgen as JOSM map paint style

  • Run roentgen mapcss.
  • Open JOSM.
  • Go to Preferences → Third tab on the left → Map Paint Styles.
  • Active styles: press +.
  • URL / File: set path to out/roentgen_mapcss/roentgen.mapcss.

To enable / disable Röntgen map paint style go to ViewMap Paint StylesRöntgen.

Example

JOSM example

Example of using Röntgen icons on top of Mapnik style. Map Paint Styles:

  • ✓ Mapnik
  • ✓ Röntgen