https://github.com/enzet/map-machine Skip to content Navigation Menu Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} enzet / map-machine Public * Notifications * Fork 20 * Star 309 * Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible License MIT license 309 stars 20 forks Branches Tags Activity Star Notifications * Code * Issues 51 * Pull requests 4 * Discussions * Actions * Projects 5 * Wiki * Security * Insights Additional navigation options * Code * Issues * Pull requests * Discussions * Actions * Projects * Wiki * Security * Insights enzet/map-machine This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main BranchesTags Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 1,391 Commits .github/workflows .github/ workflows data data doc doc map_machine map_machine tests tests .dockerignore .dockerignore .gitattributes .gitattributes .gitignore .gitignore CHANGELOG.md CHANGELOG.md CONTRIBUTING.md CONTRIBUTING.md Dockerfile Dockerfile LICENSE LICENSE README.md README.md requirements.txt requirements.txt setup.py setup.py View all files Repository files navigation * README * MIT license The Map Machine project consists of * a Python OpenStreetMap renderer: + SVG map generation, + SVG and PNG tile generation, * the Rontgen icon set: unique CC-BY 4.0 map icons. 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. See * installation instructions, * map features, * using Rontgen as JOSM style. Usage example map-machine render -b 2.284,48.860,2.290,48.865 will automatically download OSM data and render an 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 render PNG tiles that cover the specified area to the out/tiles directory. See Tile generation. Rontgen icon set The central feature of the project is the Rontgen icon set. It is a set of monochrome 14 x 14 px pixel-aligned icons specially created for the Map Machine project. Unlike the Map Machine source code, which is under the MIT license, all icons are under the CC BY license. So, with the appropriate credit the 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 an icon grid and sets of individual icons with map-machine icons. It will update the doc/grid.svg file, and create SVG files in the out/icons_by_id directory where files are named using shape identifiers (e.g. power_tower_portal_2_level.svg) and in the icons_by_name directory where files are named using shape names (e.g. Rontgen portal two-level transmission tower.svg). Files from the last directory are used in the OpenStreetMap wiki (e.g. File:Rontgen_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 can 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. Example map-machine render -c -26.19049,28.05605 -s 600,400 --buildings isometric 3D buildings Road lanes To determine the 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. Example map-machine render -c 47.61224,-122.33866 -s 600,400 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. Example 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 (15o 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. Example map-machine render -c 52.50892,13.3244 -s 600,400 -z 18.5 Surveillance Viewpoints Power tower design Visualize design values used with power = tower and power = pole tags. design has more than 1 million usages in OpenStreetMap. 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 the colour tag value to paint subway lines. Building colors Emergency Emergency Japanese map symbols Japanese maps usually use special symbols called chizukigou (Di Tu Ji Hao ) which are different from standard map symbols used in other countries. They can be enabled with --country jp option. Japanese map symbols Indoor features Draw indoor features specifying level with --level option. Possible values are numbers (e.g. 1, 0.5), lists of number separated by ; (e.g. 1;2;4;4.5), all, overground, and underground. The default value is not all, but overground, so underground objects are not shown on the map if --level option is not specified. Example map-machine render -c 4.5978,-74.07507 -s 600,400 -z 19.5 --level 0 Indoor Shape combination One of the key features of Map Machine is constructing icons from several shapes. Masts For man_made = mast distinguish types (communication, lighting, 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 scoria) 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. * Install the cairo 2D graphic library, * install the GEOS library, * install the Python packages with the command: pip install git+https://github.com/enzet/map-machine For more detailed instructions, see instructions. Map generation The render command is used to generate an SVG map from OpenStreetMap data. You can run it using: map-machine render \ -b ,,, \ -o \ -z \ Example map-machine render \ --boundary-box 2.284,48.860,2.290,48.865 \ --output out/esplanade_du_trocadero.svg will download OSM data to cache/2.284,48.860,2.290,48.865.osm and render an SVG map of the specified area to out/ esplanade_du_trocadero.svg. Arguments Option Description input XML file name or names (if not -i, --input specified, file will be downloaded using the OpenStreetMap API) -o, --output output SVG file name, default value: out/ map.svg -b, --boundary-box ,,, geo boundary box --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 // --cache path for temporary OSM files, default value: cache -b, --boundary-box construct the minimum amount of tiles that ,,, cover the requested boundary box OSM zoom levels; can be list of numbers or -z, --zoom ranges, e.g. 16-18, 16,17,18, or 16,18-20, default value: 18 input OSM XML file name (if not specified, the -i, --input file will be downloaded using the OpenStreetMap API) plus map configuration options Generate one tile Specify the tile coordinates: map-machine tile --tile // or specify any geographical coordinates inside a tile: map-machine tile \ --coordinates , \ --zoom The tile will be stored as an SVG file out/tiles/tile__ _.svg and a PNG file out/tiles/tile___.svg, where x and y are tile coordinates. The --zoom option will be ignored if it is used with the --tile option. Example: map-machine tile -c 55.7510637,37.6270761 -z 18 will generate an SVG file out/tiles/tile_18_158471_81953.svg and a PNG file out/tiles/tile_18_158471_81953.png. Generate a set of tiles Specify the boundary box to get the minimal set of tiles that covers the area: map-machine tile \ --boundary-box ,,, \ --zoom 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. The map with the 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 The server command is used to run a 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: 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:
Map options Map configuration options used by render and tile commands: Option Description scheme identifier (look for .yml file) or --scheme or path to a YAML scheme file, default value: default --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 two-letter code (ISO 3166-1 alpha-2) of --country 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 --building-colors paint walls (if isometric mode is enabled) and roofs with specified colors --show-overlapped show hidden nodes with a dot MapCSS 0.2 generation The mapcss command can be used to generate a MapCSS scheme. map-machine mapcss will create an out/map_machine_mapcss directory with simple MapCSS 0.2 scheme adding icons from the Rontgen icon set to nodes and areas: .mapcss file and directory with icons. To create a MapCSS style 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 add icons for lifecycle tags; be careful: this will --lifecycle increase the number of node and area selectors by 9 times, set by default Use Rontgen 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 the Map Machine map paint style go to View - Map Paint Styles - Map Machine. Example JOSM example Example of using Rontgen icons on top of the Mapnik style in JOSM. Map Paint Styles look like this: * Mapnik (true) * Map Machine About Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible Topics python svg map maps icons openstreetmap osm svg-icons svg-map openstreetmap-renderer Resources Readme License MIT license Activity Stars 309 stars Watchers 8 watching Forks 20 forks Report repository Releases 6 tags Packages 0 No packages published Contributors 5 * @enzet * @Strubbl * @aklofas * @phillies * @not-my-profile Languages * Python 99.7% * Other 0.3% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.