Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible

Overview

Map Machine project consists of

The idea behind the Map Machine 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. Map Machine is created both for map contributors: to display all changes one made on the map even if they are small, and for map users: to dig down into the map and find every detail that was mapped.

Unlike standard OpenStreetMap layers, Map Machine is a playground for experiments where one can easily try to support any unsupported tag, proposed tagging scheme, tags with little or even single usage, deprecated ones that are still in use.

Map Machine 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. It can also use some slow algorithms for experimental features.

Usage example

map-machine 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.

map-machine 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 the out/tiles directory. See Tile generation.

Röntgen 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 specially created for Map Machine project. Unlike the Map Machine 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 a common design style, which is heavily inspired by Maki, Osmic, and Temaki.

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 the final goal is to cover all tags. However, commonly used tags have priority, other things being equal.

Generate icon grid and sets of individual icons with map-machine icons. It will update doc/grid.svg file, and create 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).

Map features

Extra icons

Map Machine uses icons to visualize tags for nodes and areas. But unlike other renderers, Map Machine 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).

Isometric building shapes

With --buildings isometric or --buildings isometric-no-parts (not set by default), buildings are drawn using isometric shapes for walls and shade in proportion to building:levels, building:min_level, height, and min_height values.

3D buildings

Road lanes

To determine road width Map Machine uses the width tag value or estimates it based on the lanes value. If lane value is specified, it also draws lane separators. This map style is highly inspired by Christoph Hormann's post Navigating the Maze.

Road lanes

Trees

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

Trees

Viewpoint and camera direction

direction tag values for tourism = viewpoint and camera:direction for man_made = surveillance are rendered with sectors displaying the direction and angle (15º if angle is not specified) or the whole circle for panorama view. Radial gradient is used for surveillance and inverted radial gradient is used for viewpoints.

Surveillance

Viewpoints

Power tower design

Visualize design values used with power = tower tag.

Power tower design

Power tower design

Colors

Map icons have colour tag value if it is present, otherwise, icons are displayed with dark grey color by default, purple color for shop nodes, red color for emergency features, and special colors for natural features. Map Machine also takes into account building:colour, roof:colour and other *:colour tags, and uses colour tag value to paint subway lines.

Building colors

Emergency

Emergency

Japanese map symbols

Japanese maps usually use special symbols called chizukigou (地図記号) which are different from standard map symbols used in other countries. They can be enabled with --country jp option.

Japanese map symbols

Shape combination

One of the key features of Map Machine is constructing icons from the several shapes.

Masts

For man_made = mast distinguish types (communication, lignting, monitoring, and siren) and construction (freestanding or lattice, and using of guys) are rendered by combining 7 unique icon shapes.

Mast types

Volcanoes

For natural = volcano status (active, dormant, extinct, or unspecified) and type (stratovolcano, shield, or scorial) are rendered by combining 7 unique icon shapes.

Volcano types

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 author.

Author mode

Installation

Requirements: Python 3.9.

pip install .

Map generation

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

map-machine render \
    -b <min longitude>,<min latitude>,<max longitude>,<max latitude> \
    -o <output file name> \
    -z <OSM zoom level> \
    <other arguments>

Example

map-machine 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 an output SVG map of the specified area to out/esplanade_du_trocadéro.svg.

Arguments

Option Description
-i, --input input XML file name or names (if not specified, file will be downloaded using OpenStreetMap API)
-o, --output output SVG file name, default value: out/map.svg
-b, --boundary-box , , , geo boundary box; if the first value is negative, enclose the value with quotes and use space before -
--cache path for temporary OSM files, default value: cache
-z, --zoom OSM zoom level, default value: 18.0
-c, --coordinates , coordinates of any location inside the tile
-s, --size , resulted image size

plus map configuration options

Tile generation

Command tile is used to generate PNG tiles for slippy maps. To use them, run Map Machine tile server.

Option Description
-c, --coordinates , coordinates of any location inside the tile
-t, --tile / / tile specification
--cache path for temporary OSM files, default value: cache
-b, --boundary-box , , , construct the minimum amount of tiles that cover the requested boundary box
-z, --zoom OSM zoom levels; can be list of numbers or ranges, e.g. 16-18, 16,17,18, or 16,18-20, default value: 18
-i, --input input OSM XML file name (if not specified, the file will be downloaded using OpenStreetMap API)

plus map configuration options

Generate one tile

Specify tile coordinates:

map-machine tile --tile <OSM zoom level>/<x>/<y>

or specify any geographical coordinates inside a tile:

map-machine tile \
    --coordinates <latitude>,<longitude> \
    --zoom <OSM zoom levels>

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

Example:

map-machine tile -c 55.7510637,37.6270761 -z 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:

map-machine tile \
    --boundary-box <min longitude>,<min latitude>,<max longitude>,<max latitude> \
    --zoom <OSM zoom levels>

The boundary box will be extended to the boundaries of the minimal tileset 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_ _ _ .svg and PNG files out/tiles/tile_ _ _ .svg , where x and y are tile coordinates.

Example:

map-machine tile -b 2.361,48.871,2.368,48.875

will generate 36 PNG tiles at zoom level 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.

map-machine server

Stop server interrupting the process with Ctrl + C.

Option Description
--cache path for temporary OSM files, default value: cache
--port port number, default value: 8080

Example

Create a minimal amount of tiles that cover specified boundary box for zoom levels 16, 17, 18, and 19:

map-machine tile -b 2.364,48.854,2.367,48.857 -z 16-19

Run tile server on 127.0.0.1:8080:

map-machine server

Use JavaScript code for Leaflet:

OpenStreetMap ' + 'contributors, imagery © ' + 'Map Machine', id: 'map_machine', tileSize: 256, zoomOffset: 0 }).addTo(map);">
var map = L.map('mapid').setView([48.8555, 2.3655], 18);

L.tileLayer('http://127.0.0.1:8080/tiles/{z}/{x}/{y}', {
    maxZoom: 19,
    attribution: 'Map data © ' +
        'OpenStreetMap ' +
        'contributors, imagery © ' +
        'Map Machine',
    id: 'map_machine',
    tileSize: 256,
    zoomOffset: 0
}).addTo(map);

HTML code:

">
<div id="mapid" style="width: 1000px; height: 600px;">div>

Map options

Map configuration options used by render and tile commands:

Option Description
--buildings building drawing mode: no, flat, isometric, isometric-no-parts, default value: flat
--mode map drawing mode: normal, author, time, white, black, default value: normal
--overlap how many pixels should be left around icons and text, default value: 12
--labels label drawing mode: no, main, all, address, default value: main
--level display only this floor level, default value: overground
--seed seed for random
--tooltips add tooltips with tags for icons in SVG files
--country two-letter code (ISO 3166-1 alpha-2) of country, that should be used for location restrictions, default value: world
--ignore-level-matching draw all map features ignoring the current level
--roofs draw building roofs, set by default

MapCSS 0.2 generation

Command mapcss is used to generate MapCSS scheme. map-machine mapcss will create out/map_machine_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 Map Machine style also for ways and relations, run map-machine 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 Map Machine as JOSM map paint style

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

To enable/disable Map Machine map paint style go to ViewMap Paint StylesMap Machine.

Example

JOSM example

Example of using Röntgen icons on top of Mapnik style in JOSM. Map Paint Styles look like this:

  • ✓ Mapnik (true)
  • ✓ Map Machine
Owner
Sergey Vartanov
Sergey Vartanov
Python tools for geographic data

GeoPandas Python tools for geographic data Introduction GeoPandas is a project to add support for geographic data to pandas objects. It currently impl

GeoPandas 3.5k Jan 03, 2023
Software for Advanced Spatial Econometrics

GeoDaSpace Software for Advanced Spatial Econometrics GeoDaSpace current version 1.0 (32-bit) Development environment: Mac OSX 10.5.x (32-bit) wxPytho

GeoDa Center 38 Jan 03, 2023
This is the antenna performance plotted from tinyGS reception data.

tinyGS-antenna-map This is the antenna performance plotted from tinyGS reception data. See their repository. The code produces a plot that provides Az

Martin J. Levy 14 Aug 21, 2022
iNaturalist observations along hiking trails

This tool reads the route of a hike and generates a table of iNaturalist observations along the trails. It also shows the observations and the route of the hike on a map. Moreover, it saves waypoints

7 Nov 11, 2022
Computer Vision in Python

Mahotas Python Computer Vision Library Mahotas is a library of fast computer vision algorithms (all implemented in C++ for speed) operating over numpy

Luis Pedro Coelho 792 Dec 20, 2022
Tools for the extraction of OpenStreetMap street network data

OSMnet Tools for the extraction of OpenStreetMap (OSM) street network data. Intended to be used in tandem with Pandana and UrbanAccess libraries to ex

Urban Data Science Toolkit 47 Sep 21, 2022
Obtain a GNSS position fix from an 11-millisecond raw GNSS signal snapshot

Obtain a GNSS position fix from an 11-millisecond raw GNSS signal snapshot without any prior knowledge about the position of the receiver and only coarse knowledge about the time.

Jonas Beuchert 2 Nov 17, 2022
PyTorch implementation of ''Background Activation Suppression for Weakly Supervised Object Localization''.

Background Activation Suppression for Weakly Supervised Object Localization PyTorch implementation of ''Background Activation Suppression for Weakly S

34 Dec 27, 2022
Implemented a Google Maps prototype that provides the shortest route in terms of distance

Implemented a Google Maps prototype that provides the shortest route in terms of distance, the fastest route, the route with the fewest turns, and a scenic route that avoids roads when provided a sou

1 Dec 26, 2021
A simple python script that, given a location and a date, uses the Nasa Earth API to show a photo taken by the Landsat 8 satellite. The script must be executed on the command-line.

What does it do? Given a location and a date, it uses the Nasa Earth API to show a photo taken by the Landsat 8 satellite. The script must be executed

Caio 42 Nov 26, 2022
Track International space station with python

NASA-ISS-tracker Track International space station with python Modules import json import turtle import urllib.request import time import webbrowser i

Nikhil Yadav 8 Aug 12, 2021
A python package that extends Google Earth Engine.

A python package that extends Google Earth Engine GitHub: https://github.com/davemlz/eemont Documentation: https://eemont.readthedocs.io/ PyPI: https:

David Montero Loaiza 307 Jan 01, 2023
A ninja python package that unifies the Google Earth Engine ecosystem.

A Python package that unifies the Google Earth Engine ecosystem. EarthEngine.jl | rgee | rgee+ | eemont GitHub: https://github.com/r-earthengine/ee_ex

47 Dec 27, 2022
Code and coordinates for Matt's 2021 xmas tree

xmastree2021 Code and coordinates for Matt's 2021 xmas tree This repository contains the code and coordinates used for Matt's 2021 Christmas tree, as

Stand-up Maths 117 Jan 01, 2023
ColoringMapAlgorithm-CSP- - Graphical Coloring of Countries with Condition Satisfaction Algorithm

ColoringMapAlgorithm-CSP- Condition Satisfaction Algorithm Output Condition

Kerem TAN 2 Jan 10, 2022
Python interface to PROJ (cartographic projections and coordinate transformations library)

pyproj Python interface to PROJ (cartographic projections and coordinate transformations library). Documentation Stable: http://pyproj4.github.io/pypr

832 Dec 31, 2022
Creates 3D geometries from 2D vector graphics, for use in geodynamic models

geomIO - creating 3D geometries from 2D input This is the Julia and Python version of geomIO, a free open source software to generate 3D volumes and s

3 Feb 01, 2022
gjf: A tool for fixing invalid GeoJSON objects

gjf: A tool for fixing invalid GeoJSON objects The goal of this tool is to make it as easy as possible to fix invalid GeoJSON objects through Python o

Yazeed Almuqwishi 91 Dec 06, 2022
glTF to 3d Tiles Converter. Convert glTF model to Glb, b3dm or 3d tiles format.

gltf-to-3d-tiles glTF to 3d Tiles Converter. Convert glTF model to Glb, b3dm or 3d tiles format. Usage λ python main.py --help Usage: main.py [OPTION

58 Dec 27, 2022
Download and process satellite imagery in Python using Sentinel Hub services.

Description The sentinelhub Python package allows users to make OGC (WMS and WCS) web requests to download and process satellite images within your Py

Sentinel Hub 659 Dec 23, 2022