tilekiln


Nametilekiln JSON
Version 0.6.2 PyPI version JSON
download
home_pageNone
SummaryA set of command-line utilities to generate and serve Mapbox Vector Tiles (MVTs)
upload_time2024-11-08 04:57:45
maintainerNone
docs_urlNone
authorNone
requires_python<4,>=3.10
licenseNone
keywords mvt openstreetmap osm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://tilemaker.org/) or [planetiler](https://github.com/onthegomap/planetiler) may be simpler to host.

## Requirements

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

[OpenStreetMap Carto's](https://github.com/gravitystorm/openstreetmap-carto/blob/master/INSTALL.md#openstreetmap-data) 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`
*Not yet implemented.*
Generate all tiles by zoom.

#### `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 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.

## 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

```sh
git clone https://github.com/osm2pgsql-dev/osm2pgsql-themepark.git
python3 -m venv tilekiln
tilekiln/bin/pip install tilekiln
createdb flex
psql -d flex -c 'CREATE EXTENSION postgis;'
createdb tiles
```

### Loading data
We have to produce a tilekiln config from the osm2pgsql-themepark config. This requires uncommenting a line in the config.

```sh
sed -i -E -e "s/--.*(themepark:plugin\('tilekiln'\):write_config\('tk'\))/\1/" ./osm2pgsql-themepark/config/shortbread_gen.lua
LUA_PATH="./osm2pgsql-themepark/lua/?.lua;;" osm2pgsql -d flex -O flex -S ./osm2pgsql-themepark/config/shortbread_gen.lua osm-data.pbf
LUA_PATH="./osm2pgsql-themepark/lua/?.lua;;" osm2pgsql-gen -d flex -S ./osm2pgsql-themepark/config/shortbread_gen.lua
mkdir -p downloads
osm2pgsql-themepark/themes/external/download-and-import.sh ./downloads flex oceans ocean
```

### Serve some tiles

```sh
tilekiln/bin/tilekiln dev --config shortbread_config/config.yaml --source-dbname flex
```

Use the tilejson URL `http://127.0.0.1:8000/tilejson.json` to load tiles into your preferred tile viewer such as QGIS.

### Set up storage

```sh
createdb tiles
tilekiln/bin/tilekiln storage init --storage-dbname tiles --config shortbread_config/config.yaml
```

## 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](https://creativecommons.org/licenses/by/4.0/). 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/>

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tilekiln",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.10",
    "maintainer_email": null,
    "keywords": "mvt, openstreetmap, osm",
    "author": null,
    "author_email": "Paul Norman <osm@paulnorman.ca>",
    "download_url": "https://files.pythonhosted.org/packages/48/8c/1f9195f054bf47c0dfbf4cf34b231bcc87c1ebb19c61d47e33a00d4cdff9/tilekiln-0.6.2.tar.gz",
    "platform": null,
    "description": "# Tilekiln\n\n## Background\n\nTilekiln is a set of command-line utilities to generate and serve Mapbox Vector Tiles (MVTs).\n\nGeneration relies on the standard method of a PostgreSQL + PostGIS server as a data source, and ST_AsMVT to serialize the MVTs.\n\nThe 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](https://tilemaker.org/) or [planetiler](https://github.com/onthegomap/planetiler) may be simpler to host.\n\n## Requirements\n\nTilekiln requires a PostGIS database with data loaded to generate vector tiles.\n\n[OpenStreetMap Carto's](https://github.com/gravitystorm/openstreetmap-carto/blob/master/INSTALL.md#openstreetmap-data) directions are a good starting place for loading OpenStreetMap data into a PostGIS database, but any PostGIS data source in EPSG 3857 will work.\n\n- PostgreSQL 10+\n- PostGIS 3.1+\n- Python 3.10\n\n## Concepts\n\nTilekiln 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.\n\nUtility commands allow checking of configurations, storage management, and debugging as well as commands for monitoring metrics needed in production.\n\n## Usage\nTilekiln 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.\n\n### CLI commands\nCLI commands will perform a task then exit, returning to ther shell.\n\n#### `config`\nCommands to work with and check config files\n\n##### `config test`\nTests a config for validity.\n\nThe process will exit with exit code 0 if tilekiln can load the config.\n\nThis is intended for build and CI scripts used by configs.\n\n##### `config sql`\nPrint the SQL for a tile or layer.\n\nPrints the SQL that would be issued to generate a particular tile layer,\nor if no layer is given, the entire tile. This allows manual debugging of\na tile query.\n\n#### `generate`\nCommands for tile generation.\n\nAll tile generation commands run queries against the source database which\nhas the geospatial data.\n\n##### `generate tiles`\nGenerate specific tiles.\n\nA list of z/x/y tiles is read from stdin and those tiles are generated and\nsaved to storage. The entire list is read before deletion starts.\n\n##### `generate zoom`\n*Not yet implemented.*\nGenerate all tiles by zoom.\n\n#### `storage`\nCommands working with tile storage.\n\nThese commands allow creation and manipulation of the tile storage database.\n\n##### `storage init`\nInitialize storage for a tileset.\n\nCreates the storage for a tile layer and stores its metadata in the database.\nIf the metadata tables have not yet been created they will also be setup.\n\n##### `storage destroy`\nDestroy storage for a tileset.\n\nRemoves the storage for a tile layer and deletes its associated metadata.\nThe metadata tables themselves are not removed.\n\n##### `storage delete`\nMass-delete tiles from a tileset\n\nDeletes tiles from a tileset, by zoom, or delete all zooms.\n\n##### `storage tiledelete`\nDelete specific tiles.\n\nA list of z/x/y tiles is read from stdin and those tiles are deleted from\nstorage. The entire list is read before deletion starts.\n\n### Serving commands\nThese commands start a HTTP server to serve content.\n#### `serve`\nCommands for tile serving.\n\nAll tile serving commands serve tiles and a tilejson over HTTP.\n\n##### `dev`\nStarts 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.\n\n##### `live`\nLike `serve`, but fall back to live generation if a tile is missing from storage.\n\nIt presents a tilejson at `/<id>/tilejson.json`.\n\n##### `static`\nServes tiles from tile storage. This is highly scalable and the preferred mode for production.\n\nIt presents a tilejson at `/<id>/tilejson.json`. In the future it will allow serving multiple tilesets.\n\n## Quick-start\nThese 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.\n\n### Install and setup\n\n```sh\ngit clone https://github.com/osm2pgsql-dev/osm2pgsql-themepark.git\npython3 -m venv tilekiln\ntilekiln/bin/pip install tilekiln\ncreatedb flex\npsql -d flex -c 'CREATE EXTENSION postgis;'\ncreatedb tiles\n```\n\n### Loading data\nWe have to produce a tilekiln config from the osm2pgsql-themepark config. This requires uncommenting a line in the config.\n\n```sh\nsed -i -E -e \"s/--.*(themepark:plugin\\('tilekiln'\\):write_config\\('tk'\\))/\\1/\" ./osm2pgsql-themepark/config/shortbread_gen.lua\nLUA_PATH=\"./osm2pgsql-themepark/lua/?.lua;;\" osm2pgsql -d flex -O flex -S ./osm2pgsql-themepark/config/shortbread_gen.lua osm-data.pbf\nLUA_PATH=\"./osm2pgsql-themepark/lua/?.lua;;\" osm2pgsql-gen -d flex -S ./osm2pgsql-themepark/config/shortbread_gen.lua\nmkdir -p downloads\nosm2pgsql-themepark/themes/external/download-and-import.sh ./downloads flex oceans ocean\n```\n\n### Serve some tiles\n\n```sh\ntilekiln/bin/tilekiln dev --config shortbread_config/config.yaml --source-dbname flex\n```\n\nUse the tilejson URL `http://127.0.0.1:8000/tilejson.json` to load tiles into your preferred tile viewer such as QGIS.\n\n### Set up storage\n\n```sh\ncreatedb tiles\ntilekiln/bin/tilekiln storage init --storage-dbname tiles --config shortbread_config/config.yaml\n```\n\n## History\nThe 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.\n\n## License\n\n### Code\n\nCopyright \u00a9 2022-2024 Paul Norman <osm@paulnorman.ca>\n\nThe code is licensed terms of the GNU General Public License as\npublished by the Free Software Foundation, either version 3 of\nthe License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see <http://www.gnu.org/licenses/>.\n\n### Documentation\n\nThe text of the documentation and configuration format specification is licensed under a [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/). However, the use of the specification in products and code is entirely free: there are no royalties, restrictions, or requirements.\n\n### Sample configuration\n\nThe sample configuration files are released under the CC0 Public\nDomain Dedication, version 1.0, as published by Creative Commons.\nTo the extent possible under law, the author(s) have dedicated all\ncopyright and related and neighboring rights to the Software to\nthe public domain worldwide. The Software is distributed WITHOUT\nANY WARRANTY.\n\nIf you did not receive a copy of the CC0 Public Domain Dedication\nalong with the Software, see\n<http://creativecommons.org/publicdomain/zero/1.0/>\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A set of command-line utilities to generate and serve Mapbox Vector Tiles (MVTs)",
    "version": "0.6.2",
    "project_urls": {
        "Bug Reports": "https://github.com/pnorman/tilekiln/issues",
        "Homepage": "https://github.com/pnorman/tilekiln",
        "Source": "https://github.com/pnorman/tilekiln/"
    },
    "split_keywords": [
        "mvt",
        " openstreetmap",
        " osm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "27b6e6924df0463fd078adc5f8a0ffae0cf3d92d1f33175a7c2fd6a94ef30477",
                "md5": "6ead395328434696501a0cede691d61c",
                "sha256": "bbd34c40179c70711fa584a864552cb329614d0567f09795d65b749629bd76ac"
            },
            "downloads": -1,
            "filename": "tilekiln-0.6.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6ead395328434696501a0cede691d61c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.10",
            "size": 37952,
            "upload_time": "2024-11-08T04:57:43",
            "upload_time_iso_8601": "2024-11-08T04:57:43.415817Z",
            "url": "https://files.pythonhosted.org/packages/27/b6/e6924df0463fd078adc5f8a0ffae0cf3d92d1f33175a7c2fd6a94ef30477/tilekiln-0.6.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "488c1f9195f054bf47c0dfbf4cf34b231bcc87c1ebb19c61d47e33a00d4cdff9",
                "md5": "706e14d1f9daeee72a05eb3df45fafef",
                "sha256": "c743277cb370a1bd66e3f4a90ecd81658deca0bf830b966f23adf5432890c7c8"
            },
            "downloads": -1,
            "filename": "tilekiln-0.6.2.tar.gz",
            "has_sig": false,
            "md5_digest": "706e14d1f9daeee72a05eb3df45fafef",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.10",
            "size": 30533,
            "upload_time": "2024-11-08T04:57:45",
            "upload_time_iso_8601": "2024-11-08T04:57:45.402575Z",
            "url": "https://files.pythonhosted.org/packages/48/8c/1f9195f054bf47c0dfbf4cf34b231bcc87c1ebb19c61d47e33a00d4cdff9/tilekiln-0.6.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-08 04:57:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pnorman",
    "github_project": "tilekiln",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "tilekiln"
}
        
Elapsed time: 1.25231s