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.3.tar.gz (10.2 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.3-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tile_archive_utils-0.0.3.tar.gz
Algorithm Hash digest
SHA256 7c3a46e5791a0732f0fc1181ad80bb53c3c19a3934accc39029bcb0f84bdb64a
MD5 49f1f0ce180ef53c9f6e45567d1819ba
BLAKE2b-256 c64167173da3f4860c212d557ac3a82d7af1f76e990f9403ec785a0060d3c6b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tile_archive_utils-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bf6f99a0933c1057a342d4d435e379295297a441eaf43313f449efe2eedcdf85
MD5 b883767fc34413ae639cb42e9617284e
BLAKE2b-256 1d4cc9c52a79d41e6d035cd007734cebbc23acaaed79fea6e7c0b70ddff2fc7c

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