Skip to main content

Utilities facilitating tile extraction from and integration into tile archives

Project description

Tile Archive Utils

This package provides command-line utilities supporting the extraction of tiles from PMTiles archives to ZXY directories and the construction of MBTiles archives from ZXY directories. Combined with the PMTiles command-line utilities, this package makes it possible to extract tiles from a PMTiles archive, transform the tiles, and assemble the transformed tiles into a derivative PMTiles archive.

Installation

Install GDAL + Python bindings (Required)

Option 1: Using conda (Recommended)

conda install -c conda-forge gdal

This installs both the GDAL library and the Python bindings, eliminating the risk of version mismatch.

Option 2: Using system package manager + pip

# Ubuntu/Debian
sudo apt-get install gdal-bin libgdal-dev
pip install gdal

# macOS with Homebrew  
brew install gdal
pip install gdal

Ensure the GDAL library and Python binding versions match for proper execution.

Note that Docker is discouraged for use with this package as the volume of file I/O significantly degrades performance when running within a VM.

Install tile-archive-utils

pip install tile-archive-utils

Commands

After installation, you'll have access to two command-line tools:

pmtiles-zxy

Extracts tiles from a PMTiles archive into a ZXY hierarchical directory structure.

pmtiles-zxy <PMTiles archive> <output directory> <min zoom> <max zoom>

Example:

# Extract zoom levels 0-10 from map.pmtiles to the directory tiles
pmtiles-zxy tileset.pmtiles tiles 0 10

Features:

  • Robust extraction with detailed error reporting
  • Progress tracking with tqdm
  • Seamless continuation following interruptions
  • Memory-efficient processing by zoom level
  • Built-in GDAL script bundling

zxy-mbtiles

Converts ZXY hierarchical directory structures into MBTiles archives.

zxy-mbtiles <ZXY directory> <output MBTiles file> [options]

Options:

  • --name <string>: Tileset name
  • --description <string>: Tileset description
  • --format <format>: Tile format (default: png, supports: png, jpg, webp, pbf)
  • --batchsize <integer>: Tile batch size for database inserts (default: 1000)
  • --flip-y: Flip Y tile coordinate (XYZ/Slippy <--> TMS conversion)

Examples:

# Basic conversion
zxy-mbtiles tiles tileset.mbtiles

# With custom metadata
zxy-mbtiles tiles tileset.mbtiles --name "Hillshade tiles" --description "Pre-rendered terrain data"

# With tile format and batch size specified
zxy-mbtiles tiles tileset.mbtiles --format jpg --batchsize 10000

# With Y tile coordinate conversion
zxy-mbtiles tiles tileset.mbtiles --flip-y

Features:

  • Optimized SQLite database creation
  • Progress tracking with tqdm
  • Multiple tile format support

Directory Structure

The package has the following structure:

tile-archive-utils/
├── pyproject.toml
├── README.md
├── src/
│   └── tile_archive_utils/
│       ├── __init__.py
│       ├── pmtiles_to_zxy.py    # PMTiles → ZXY converter
│       ├── zxy_to_mbtiles.py    # ZXY → MBTiles converter
│       └── gdal_cp.py           # Bundled GDAL utility

Requirements

  • Python 3.10+
  • GDAL + Python bindings
  • tqdm
  • click

ZXY Directory Format

The ZXY format follows this hierarchical structure:

tiles/
├── 0/
│   └── 0/
│       └── 0.png
├── 1/
│   ├── 0/
│   │   ├── 0.png
│   │   └── 1.png
│   └── 1/
│       ├── 0.png
│       └── 1.png
└── ...

Where:

  • First level: Zoom level (Z)
  • Second level: Column/X coordinate
  • Files: Row/Y coordinate with tile extension

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

tile_archive_utils-0.0.4.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

tile_archive_utils-0.0.4-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file tile_archive_utils-0.0.4.tar.gz.

File metadata

  • Download URL: tile_archive_utils-0.0.4.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for tile_archive_utils-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9bf33d2b9d043c0923dbd530301a37f17fe9471e2ddde7800e378f3cc3bfc30b
MD5 c48c83b40bcfd25fd62c69b4854788bf
BLAKE2b-256 cfcb2deb40568bba86cd21b91964e79869516b982f67d59016d9728c2ef44cc7

See more details on using hashes here.

File details

Details for the file tile_archive_utils-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for tile_archive_utils-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e7bd5281981b65c52b0b21821c3d407d51897a187ea34640ce6a59a7254c625b
MD5 85b0399cc090546962457bc09ea80380
BLAKE2b-256 19f83b5b3f29294750ca47479ee14179e7ff4e83c811624feeae9132f5aeffb5

See more details on using hashes here.

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