Skip to main content

mbmerge

Build incremental, lossless raster MBTiles mosaics: merge one common highest source zoom first, then generate lower zooms from the merged detail. PNG/WebP alpha compositing, bounded batches, parallel workers, one SQLite writer, and crash-safe recovery of both phases.

Installation

pipx install mbmerge
mbmerge --version

Or use python -m pip install mbmerge in a virtual environment. Requires Linux/macOS, Python 3.11+, SQLite 3.35+ and Pillow (installed as a dependency). Windows is not supported. WebP needs Pillow's WebP codec.

Usage

mbmerge merge --input-dir /data/inputs --output /data/mosaic.mbtiles

# Choose a common base level and generate zooms 5..16 as PNG:
mbmerge merge --input-dir /data/inputs --output /data/mosaic-png.mbtiles \
  --base-zoom 16 --min-zoom 5 --output-format png

# Keep supplied zoom artwork instead of generating a pyramid:
mbmerge merge --mode overlay --input-dir /data/inputs --output /data/overlay.mbtiles

mbmerge status --output /data/mosaic.mbtiles
mbmerge verify --output /data/mosaic.mbtiles --decode

New outputs default to pyramid mode and lossless WebP. Automatic base selection requires the same actual highest zoom in every nonempty input. An explicit base must exist in every nonempty input. Only the selected level is imported; supplied lower overviews are ignored. After ordered source compositing, lower levels are generated from up to four current children with premultiplied-alpha BOX averaging. Missing children are transparent. On later imports only affected ancestors are rebuilt.

Repeat the merge command after interruption. Completed unchanged sources are skipped. New sources append after earlier layers; an interrupted active source finishes first. Dirty parent keys and their progress are persisted atomically with pixels. Publish only phase complete; verify rejects incomplete/tainted outputs. During updates readers may see new detail and stale overviews.

Lossless encoding

PNG and WebP outputs are lossless. WebP explicitly uses lossless=True, exact=True; quality=100 alone would not guarantee lossless RGB. Unique matching PNG/lossless WebP tiles may retain their original bytes. Lossy WebP input is transcoded losslessly even without overlap; source losses cannot be restored. Image compositing/downsampling still involves 8-bit rounding and lower spatial resolution.

Input and operating limits

Inputs must be immutable, offline flat MBTiles with a unique ascending BINARY index on (zoom_level,tile_column,tile_row). Coordinates use the same Web Mercator/TMS grid; square dimensions must match (default 512 px). Static WebP and PNG up to 8 bits/channel can be mixed. Animations, 16-bit PNG, JPEG, vectors, normalized layouts and WAL-mode inputs are rejected. merge performs no reprojection. mbmerge tile (needs GDAL ≥ 3.11 command-line tools) creates such inputs from GeoTIFF/PDF/VRT/JPEG with polygon clipping, nodata/collar handling and lossless packing. --reimport changed|always overlays a new version of an imported source again; --verify-recorded stat avoids re-hashing a large unchanged history.

Version 2 uses schema 3 and changes the default to pyramid generation. Existing version 1.x outputs are refused without modification; rebuild to a new output from original sources. Other existing archives can be explicitly used as flattened inputs, never adopted as managed outputs. Mode, base/minimum zoom, format, tile size and active encoder settings are fixed after importing starts.

Changed historical sources are rejected. Keep their recorded paths available; restore exact original bytes or rebuild. Every invocation hashes all historical sources, so use a single input list/directory for the initial collection rather than invoking once per file.

Jobs, blob bytes and image dimensions are bounded; pending parent keys live on disk. The batch budget is not an absolute RSS cap. Pyramid mode requires a byte budget at least five times the maximum tile size in bytes (four children and a parent). Use local SQLite-compatible storage, avoid long output-reader transactions and allow free space for output/WAL/indexes. Bounds use source extents or base tile footprints without alpha cropping. A real 1 TB collection has not been validated.

Use mbmerge merge --help for limits. python -m mbmerge is supported. The repository contains English/Czech docs, synthetic demos, crash tests and reproducible memory/many-file benchmarks.

License

MIT License. Copyright (c) 2026 mbmerge contributors.

Metadata

Release files for mbmerge 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mbmerge 2.1.0
File Size Uploaded Provenance Actions
mbmerge-2.1.0.tar.gz 266.4 kB With provenance Details for mbmerge-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mbmerge 2.1.0
File Interpreter ABI Platform Actions
mbmerge-2.1.0-py3-none-any.whl Python 3 none any Details for mbmerge-2.1.0-py3-none-any.whl

Total release size: 304.1 kB

Release files / mbmerge-2.1.0.tar.gz

Download URL mbmerge-2.1.0.tar.gz
Size 266.4 kB
Tags Source
SHA-256 checksum
How to use checksums
68f508c5edeed0561ecf2acc807452463671f5ea2836ab4d2e574f1b6945ae65
BLAKE2b-256 checksum
How to use checksums
682edcae0a17035614e428f38d8194130b69d85f29bfe0a9bf87b4284c646d55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / mbmerge-2.1.0-py3-none-any.whl

Download URL mbmerge-2.1.0-py3-none-any.whl
Size 37.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e62051642d09b0fc60a2b00c8394db6d8397ae1b2c560cf2c40c46ccb28f60a
BLAKE2b-256 checksum
How to use checksums
3a00f44066a2e1f416dcc32804510d01c2a7a303c4ffad542e86d78d4b423bb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for mbmerge 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mbmerge-2.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page