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)

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

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.2.tar.gz (10.0 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.2-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tile_archive_utils-0.0.2.tar.gz
Algorithm Hash digest
SHA256 040d3fe1ef558daec191f2876193fe02b624a5dc1c91679241f4296617e8e803
MD5 8daa63bec4fcc9271a1c17e49308fc00
BLAKE2b-256 db7148d27847b439474dfd989040b7dd284fbfe3f988abd217b2f56acfba1ace

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tile_archive_utils-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ff30631dfdfc24d7a5dcdf1a9981b0f900b877685bb7dc03d3a954ab0c25c965
MD5 d43fb93b8a69207b84d3522b9b307611
BLAKE2b-256 1c325381d19379e3ab937aaf6abb1bcaf5cd961db5bc1c01d4166ee46b4abd42

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