Back to rankings

openmaptiles/openmaptiles

PLpgSQLopenmaptiles.org

OpenMapTiles Vector Tile Schema Implementation

vector-tilesopenstreetmapmapsopenstreetmap-datatiles
Star Growth
Stars
3.1k
Forks
671
Weekly Growth
Issues
221
1k2k3k
Jan 2017Mar 2020May 2023Jul 2026
README

OpenMapTiles Build Status

OpenMapTiles is an extensible and open tile schema based on the OpenStreetMap. This project is used to generate vector tiles for online zoomable maps. OpenMapTiles is about creating a beautiful basemaps with general layers containing topographic information. More information openmaptiles.org and maptiler.com/data/.

We encourage you to collaborate, reuse and adapt existing layers, or add your own layers. You may use our approach for your own vector tile project. Feel free to fork the repo and experiment. The repository is built on top of the openmaptiles/openmaptiles-tools to simplify vector tile creation.

Please keep in mind that OpenMapTiles schema should display general topographic content. If creating a new layer or expanding an existing layer with a specific theme, please create a fork and invite other community members to cooperate on your topic. OpenMapTiles schema is used in many projects all over the world and the size of the final vector tiles needs to be considered in any update.

Styles

You can start from several GL styles supporting the OpenMapTiles vector schema.

:link: Learn how to create Mapbox GL styles with Maputnik and OpenMapTiles.

Schema

OpenMapTiles consists out of a collection of documented and self contained layers you can modify and adapt. Together the layers make up the OpenMapTiles tileset.

:link: Study the vector tile schema

Develop

To work on OpenMapTiles you need Docker.

Microsoft Windows Subsystem for Linux (WSL)

Please use Linux /home/user/ directory, not Windows e.g. /mnt/c directory.

Build

Build the tileset.

git clone https://github.com/openmaptiles/openmaptiles.git
cd openmaptiles
# Build the imposm mapping, the tm2source project and collect all SQL scripts
make

You can execute the following manual steps (for better understanding) or use the provided quickstart.sh script to automatically download and import given area. If area is not given, Albania will be imported. List of available areas make list-geofabrik.

./quickstart.sh <area>

Prepare the Database

Now start up the database container.

make start-db

Import external data from OpenStreetMapData, Natural Earth and OpenStreetMap Lake Labels. Natural Earth country boundaries are used in the few lowest zoom levels.

make import-data

Download OpenStreetMap data extracts from any source like Geofabrik, and store the PBF file in the ./data directory. To use a specific download source, use download-geofabrik, download-bbbike, or download-osmfr, or use download to make it auto-pick the area. You can use area=planet for the entire OSM dataset (very large). Note that if you have more than one data/*.osm.pbf file, every make command will always require area=... parameter (or you can just export area=... first).

make download area=albania

Import OpenStreetMap data with the mapping rules from build/mapping.yaml (which has been created by make). Run after any change in layers definition (any change in mapping.yaml).

make import-osm

Import labels from Wikidata. If an OSM feature has Key:wikidata, OpenMapTiles check corresponding item in Wikidata and use its labels for languages listed in openmaptiles.yaml. So the generated vector tiles includes multi-languages in name field.

This step uses Wikidata Query Service to download just the Wikidata IDs that already exist in the database.

make import-wikidata

Work on Layers

Each time you modify a layer's mapping.yaml file or add new OSM tags, run make and make import-osm to recreate tables (potentially with additional data) in PostgreSQL. With the new data, there can be new Wikidata records also.

make clean
make
make import-osm
make import-wikidata

Each time you modify layer SQL code run make and make import-sql.

make clean
make
make import-sql

Each time you make a modification that adds a new feature to vector tiles e.g. adding new OSM tags, modify the layer style snippet by adding new style layer so the changes are propagated visually into the style. All new style layers must have the order value which determines the order or rendering in the map style. After the layer style snippet is modified run:

make build-style

Now you are ready to generate the vector tiles. By default, ./.env specifies the entire planet BBOX for zooms 0-7, but running generate-bbox-file will analyze the data file and set the BBOX param to limit tile generation.

make generate-bbox-file  # compute data bbox -- not needed for the whole planet or for downloaded area by `make download`
make generate-tiles-pg   # generate tiles

Workflow to generate tiles

If you go from top to bottom you can be sure that it will generate a .mbtiles file out of a .osm.pbf file

make clean                  # clean / remove existing build files
make                        # generate build files
make start-db               # start up the database container.
make import-data            # Import external data from OpenStreetMapData, Natural Earth and OpenStreetMap Lake Labels.
make download area=albania  # download albania .osm.pbf file -- can be skipped if a .osm.pbf file already existing
make import-osm             # import data into postgres
make import-wikidata        # import Wikidata
make import-sql             # create / import sql functions 
make generate-bbox-file     # compute data bbox -- not needed for the whole planet or for downloaded area by `make download`
make generate-tiles-pg      # generate tiles

Instead of calling make download area=albania you can add a .osm.pbf file in the data folder openmaptiles/data/your_area_file.osm.pbf

To change the name of the output filename, you can modify the variable MBTILES_FILE in the .env file or set up the environment variable MBTILES_FILE before running ./quickstart.sh or make generate-tiles-pg (e.g., MBTILES_FILENAME=monaco.mbtiles ./quickstart.sh monaco).

License

All code in this repository is under the BSD license. Design and the cartography decisions encoded in the schema and SQL are licensed under CC-BY.

Products or services using maps derived from OpenMapTiles schema need to visibly credit "OpenMapTiles.org" or reference "OpenMapTiles" with a link to https://openmaptiles.org/. Exceptions to attribution requirement can be granted on request.

For a browsable electronic map based on OpenMapTiles and OpenStreetMap data, the credit should appear in the corner of the map. For example:

© OpenMapTiles © OpenStreetMap contributors

For printed and static maps a similar attribution should be made in a textual description near the image, in the same fashion as if you cite a photograph.

Related repositories
rastapasta/mapscii

🗺 MapSCII is a Braille & ASCII world map renderer for your console - enter => telnet mapscii.me <= on Mac (brew install telnet) and Linux, connect with PuTTY on Windows

JavaScriptnpmMIT Licenseascii-artmap
9.2k293
hyperknot/openfreemap

Free and open-source map hosting solution with custom styles for websites and apps, using OpenStreetMap data

PythonPyPIOthermaplibremaplibre-gl-js
openfreemap.org
5.7k175
mapbox/mapbox-gl-native

Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL

C++Othermapmapbox-gl
mapbox.com/mobile
4.5k1.3k
maplibre/martin

Blazing fast and lightweight PostGIS, MBtiles and PMtiles tile server, tile generation, and mbtiles tooling.

Rustcrates.ioApache License 2.0rustwebserver
martin.maplibre.org
3.8k378
mapbox/tippecanoe

Build vector tilesets from large collections of GeoJSON features.

C++BSD 2-Clause "Simplified" Licensec-plus-plusgeojson
3.1k431
maptiler/tileserver-gl

Vector and raster maps with GL styles. Server side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.

JavaScriptnpmOthertileserverwmts
tileserver.readthedocs.io/en/latest/
2.9k704
maplibre/maputnik

An open source visual editor for the 'MapLibre Style Specification'

TypeScriptnpmMIT Licensemapscartography
maplibre.org/maputnik
2.6k464
tangrams/tangram

WebGL map rendering engine for creative cartography

JavaScriptnpmMIT Licensetangrammap
tangram.city
2.3k290
onthegomap/planetiler

Flexible tool to build planet-scale vector tilesets from OpenStreetMap data fast

JavaMavenApache License 2.0vector-tilesopenstreetmap
2.1k187
maplibre/maplibre-native

MapLibre Native - Interactive vector tile maps for iOS, Android and other platforms.

C++BSD 2-Clause "Simplified" Licensevector-tilesmaplibre
maplibre.org
2.1k559
systemed/tilemaker

Make OpenStreetMap vector tiles without the stack

C++Othervector-tilesopenstreetmap
tilemaker.org
1.9k282
go-spatial/tegola

Tegola is a Mapbox Vector Tile server written in Go

GoGo ModulesMIT Licensepostgisvector-tiles
tegola.io
1.5k227