Skip to main content

Convert TMS tile folders to MBTiles/PMTiles and serve them as TMS/WMTS endpoints

Project description

tilepack

CI PyPI Python License: MIT

Pack raster tile folders (TMS or XYZ) into single-file archives (MBTiles / PMTiles) and serve them as TMS and WMTS endpoints over HTTP.

Why

Raster tile folders contain thousands of small PNG files in deeply nested z/x/y directories. This makes them slow to copy, hard to manage, and fragile to transfer. Tilepack solves this by packing tiles into a single archive file while still exposing standard TMS and WMTS HTTP endpoints that clients like QGIS and CesiumForUnreal can consume directly.

Install

Requires Python 3.11+.

pip install tilepack

For development:

git clone https://github.com/ashnair1/tilepack.git
cd tilepack
uv sync --group dev

Usage

Verify a tile folder

Scan a tile folder and report zoom levels, tile counts, format, and detected Y-axis scheme (TMS vs XYZ).

tilepack verify ./path/to/tiles

Convert to archive

The output format is inferred from the file extension. The input tile scheme (TMS or XYZ) is auto-detected, or can be specified explicitly.

# Auto-detect input scheme
tilepack convert ./path/to/tiles output.mbtiles
tilepack convert ./path/to/tiles output.pmtiles

# Specify input scheme explicitly
tilepack convert ./path/to/tiles output.mbtiles --scheme xyz

Serve as TMS + WMTS endpoint

Start a local HTTP server exposing both TMS and OGC WMTS 1.0.0 endpoints from an archive file.

tilepack serve output.mbtiles --port 8000
tilepack serve output.pmtiles --port 8000

TMS endpoints:

  • http://localhost:8000/tilemapresource.xml
  • http://localhost:8000/{z}/{x}/{y}.png

WMTS endpoints:

  • http://localhost:8000/WMTSCapabilities.xml — GetCapabilities
  • http://localhost:8000/wmts/{Layer}/{TileMatrixSet}/{z}/{row}/{col}.png — RESTful tiles
  • http://localhost:8000/wmts?Service=WMTS&Request=GetTile&... — KVP tiles

To load in QGIS: Layer > Add WMS/WMTS Layer > New, set URL to http://localhost:8000/WMTSCapabilities.xml, then Connect and Add.

Validate correctness

Randomly sample tiles from the original folder, fetch them from the running server, and verify byte-exact matches.

# Start the server in one terminal, then in another:
tilepack selftest ./path/to/tiles --base-url http://127.0.0.1:8000 --samples 200

MBTiles vs PMTiles

MBTiles PMTiles
Format SQLite database Cloud-optimised archive (Hilbert-curve index)
File count 1 1
Needs a tile server Yes No (supports HTTP range requests)
Best for Local / on-prem serving Cloud storage (S3, Azure Blob, GCS)

Use MBTiles for local or on-prem serving (e.g. feeding CesiumForUnreal on the same machine or network). It's a SQLite file with fast tile lookups and no coordinate flipping at read time.

Use PMTiles if you plan to host tiles in cloud storage. PMTiles can be served directly from a bucket via HTTP range requests with no tile server needed. However, TMS clients like CesiumForUnreal cannot consume PMTiles directly — they still need a server translating to TMS endpoints.

Either format works identically when served through tilepack serve — clients see the same TMS and WMTS endpoints regardless of the backing archive.

License

MIT

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

tilepack-0.1.0.tar.gz (59.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tilepack-0.1.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file tilepack-0.1.0.tar.gz.

File metadata

  • Download URL: tilepack-0.1.0.tar.gz
  • Upload date:
  • Size: 59.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tilepack-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e2da6b1f1efc930647031447b8243489eff0587fb21e821ea9b39415a468b85c
MD5 00443e2af55e8b09e3576b86a58e01c9
BLAKE2b-256 a06b20109058034b75332c5f857ae5a18937b9bc28e0226fee0b23656e47dc9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tilepack-0.1.0.tar.gz:

Publisher: release.yml on ashnair1/tilepack

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

File details

Details for the file tilepack-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tilepack-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tilepack-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abc172b5dba111abc47e44fb0368e6dacf833ac7ef2b5d7001cf10587c13cc9c
MD5 b831705f27fed282fdd331f2fe68af1a
BLAKE2b-256 ba52010be3729f6639fcd1dbb5bff4afbc227ce3c263af7e2755567e21958756

See more details on using hashes here.

Provenance

The following attestation bundles were made for tilepack-0.1.0-py3-none-any.whl:

Publisher: release.yml on ashnair1/tilepack

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 Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page