Skip to main content

A set of command-line utilities to generate and serve Mapbox Vector Tiles (MVTs)

Project description

Tilekiln

Background

Tilekiln is a set of command-line utilities to generate and serve Mapbox Vector Tiles (MVTs).

Generation relies on the standard method of a PostgreSQL + PostGIS server as a data source, and ST_AsMVT to serialize the MVTs.

The target use-case is vector tiles for a worldwide complex basemap under high load which requires minutely updates. If only daily updates are required options like tilemaker or planetiler may be simpler to host.

Requirements

Tilekiln requires a PostGIS database with data loaded to generate vector tiles.

OpenStreetMap Carto's directions are a good starting place for loading OpenStreetMap data into a PostGIS database, but any PostGIS data source in EPSG 3857 will work.

  • PostgreSQL 10+
  • PostGIS 3.1+
  • Python 3.10

Concepts

Tilekiln issues queries against a source database to generate Mapbox Vector Tile (MVT) layers, assembles the layers into a tile, then either serves the tile to the user or stores it in a storage database. It can also serve previously generated tiles from the storage database which completely removes the source database out of the critical path for serving tiles.

Utility commands allow checking of configurations, storage management, and debugging as well as commands for monitoring metrics needed in production.

Usage

Tilekiln commands can be broken into two sets, commands which involve serving tiles, and CLI commands. Command-line options can be found with tilekiln --help, which includes a listing and description of all options.

CLI commands

CLI commands will perform a task then exit, returning to ther shell.

config

Commands to work with and check config files

config test

Tests a config for validity.

The process will exit with exit code 0 if tilekiln can load the config.

This is intended for build and CI scripts used by configs.

config sql

Print the SQL for a tile or layer.

Prints the SQL that would be issued to generate a particular tile layer, or if no layer is given, the entire tile. This allows manual debugging of a tile query.

generate

Commands for tile generation.

All tile generation commands run queries against the source database which has the geospatial data.

generate tiles

Generate specific tiles.

A list of z/x/y tiles is read from stdin and those tiles are generated and saved to storage. The entire list is read before deletion starts.

generate zoom

Generate all tiles by zoom.

generate layers

Generate specific layers for specific tiles.

storage

Commands working with tile storage.

These commands allow creation and manipulation of the tile storage database.

storage init

Initialize storage for a tileset.

Creates the storage for a tile layer and stores its metadata in the database. If the metadata tables have not yet been created they will also be setup.

storage destroy

Destroy storage for a tileset.

Removes the storage for a tile layer and deletes its associated metadata. The metadata tables themselves are not removed.

storage inspect

Print data about a stored tile

storage delete

Mass-delete tiles from a tileset

Deletes tiles from a tileset, by zoom, or delete all zooms.

storage tiledelete

Delete specific tiles.

A list of z/x/y tiles is read from stdin and those tiles are deleted from storage. The entire list is read before deletion starts.

Serving commands

These commands start a HTTP server to serve content.

serve

Commands for tile serving.

All tile serving commands serve tiles and a tilejson over HTTP.

dev

Starts a server to live-render tiles with no caching, intended for development. It presents a tilejson at /<id>/tilejson.json, and for convience /tilejson.json redirects to it.

live

Like serve, but fall back to live generation if a tile is missing from storage.

It presents a tilejson at /<id>/tilejson.json.

static

Serves tiles from tile storage. This is highly scalable and the preferred mode for production.

It presents a tilejson at /<id>/tilejson.json. In the future it will allow serving multiple tilesets.

prometheus

Starts a prometheus exporter for metrics on tiles. By default it presents metrics at http://127.0.0.1:10013/metrics.

Quick-start

These instructions give you a setup based on osm2pgsql-themepark and their shortbread setup. They assume you have PostgreSQL with PostGIS and Python 3.10+ with venv set up, and a recent version of osm2pgsql.

Install and setup

python3 -m venv tilekiln
tilekiln/bin/pip install tilekiln
tilekiln/bin/tilekiln --help

Configuration Setup

Tilekiln requires a configuration file that defines the contents of your vector tiles. Most configurations are designed to work with OpenStreetMap data loaded into PostgreSQL using osm2pgsql.

For a configuration, you can use the one provided by the Street Spirit project. Follow its installation guide to get started.

History

The tilekiln configuration syntax is based on studies and experience with other vector tile and map generation configurations. In particular, it is heavily inspired by Tilezen's use of Jinja2 templates and TileJSON for necessary metadata.

License

Code

Copyright © 2022-2024 Paul Norman osm@paulnorman.ca

The code is licensed terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Documentation

The text of the documentation and configuration format specification is licensed under a Creative Commons Attribution 4.0 International License. However, the use of the specification in products and code is entirely free: there are no royalties, restrictions, or requirements.

Sample configuration

The sample configuration files are released under the CC0 Public Domain Dedication, version 1.0, as published by Creative Commons. To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to the Software to the public domain worldwide. The Software is distributed WITHOUT ANY WARRANTY.

If you did not receive a copy of the CC0 Public Domain Dedication along with the Software, see http://creativecommons.org/publicdomain/zero/1.0/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tilekiln-0.8.1.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

tilekiln-0.8.1-py3-none-any.whl (40.8 kB view details)

Uploaded Python 3

File details

Details for the file tilekiln-0.8.1.tar.gz.

File metadata

  • Download URL: tilekiln-0.8.1.tar.gz
  • Upload date:
  • Size: 33.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tilekiln-0.8.1.tar.gz
Algorithm Hash digest
SHA256 a03b513a3603442a1a96c7ec16c1f07269d92b978bd61a5f1b5b00ec4a385719
MD5 ec65bc25bc8e5e84105493ebdddfcfb3
BLAKE2b-256 f13e36339378f28a24a3d01ba17050d0ee2f383fcb153f9e5930f9f06d459774

See more details on using hashes here.

Provenance

The following attestation bundles were made for tilekiln-0.8.1.tar.gz:

Publisher: package.yml on pnorman/tilekiln

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tilekiln-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: tilekiln-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 40.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tilekiln-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16da4dc0ffea18cc2f9b4aa4344154a4fd4de4af4cf2656f408efa716e324599
MD5 77d86e95f761c6a3a3340a070fc029ed
BLAKE2b-256 6ed848a5e5154b75167afc411e39f395d6f38a57456f5533ef558167a29f4a69

See more details on using hashes here.

Provenance

The following attestation bundles were made for tilekiln-0.8.1-py3-none-any.whl:

Publisher: package.yml on pnorman/tilekiln

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page