MBUtil
MBUtil is a utility for importing and exporting the MBTiles format, typically created with Mapbox TileMill.
Before exporting tiles to disk, see if there's a Mapbox Hosting plan or an open source MBTiles server implementation that works for you - tiles on disk are notoriously difficult to manage.
Note well: this project is no longer actively developed. Issues and pull requests will be attended to when possible, but delays should be expected.
Installation
Install with pip:
pip3 install smellman-mbutil
or use sudo if you want to install it globally:
sudo pip3 install smellman-mbutil --break-system-packages
or clone the repository and install it manually:
git clone https://github.com/smellman/mbutil.git
cd mbutil
uv venv
source .venv/bin/activate
uv pip install .
Usage
Usage: mb-util [options] input output
Examples:
Export an mbtiles file to a directory of files:
$ mb-util world.mbtiles dumps # when the 2nd argument is "dumps", then dumps the metatdata.json
Export an mbtiles file to a directory of files:
$ mb-util world.mbtiles tiles # tiles must not already exist
Import a directory of tiles into an mbtiles file:
$ mb-util tiles world.mbtiles # mbtiles file must not already exist
Options:
-h, --help show this help message and exit
--scheme=SCHEME Tiling scheme of the tiles. Default is "xyz" (z/x/y),
other options are "tms" which is also z/x/y but uses a
flipped y coordinate, and "wms" which replicates the
MapServer WMS TileCache directory structure
"z/000/000/x/000/000/y.png"
--image_format=FORMAT
The format of the image tiles, either png, jpg, webp,
pbf or mvt
--grid_callback=CALLBACK
Option to control JSONP callback for UTFGrid tiles. If
grids are not used as JSONP, you can remove callbacks
specifying --grid_callback=""
--do_compression Do mbtiles compression
--silent Dictate whether the operations should run silently
Export an mbtiles file to files on the filesystem:
mb-util World_Light.mbtiles adirectory
Import a directory into a mbtiles file
mb-util directory World_Light.mbtiles
Requirements
- Python
>= 3.8
Metadata
MBUtil imports and exports metadata as JSON, in the root of the tile directory, as a file named metadata.json.
{
"name": "World Light",
"description": "A Test Metadata",
"version": "3"
}
Testing
This project uses pytest for testing. Install pytest:
uv venv
source .venv/bin/activate
uv pip install hatch
hatch env create
hatch test
Building from Source
To build from source, clone the repository and run:
hatch build
See Also
- node-mbtiles provides mbpipe, a useful utility.
- mbliberator a similar program but in node.
License
BSD - see LICENSE.md
Authors
- Tom MacWright (tmcw)
- Dane Springmeyer (springmeyer)
- Mathieu Leplatre (leplatrem)
Metadata
Release files for smellman-mbutil 0.3.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| smellman_mbutil-0.3.10.tar.gz | 269.9 kB | Without provenance | Details for smellman_mbutil-0.3.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smellman_mbutil-0.3.10-py3-none-any.whl | Python 3 | none | any | Details for smellman_mbutil-0.3.10-py3-none-any.whl |
Total release size: 284.4 kB
Release files / smellman_mbutil-0.3.10.tar.gz
| Download URL | smellman_mbutil-0.3.10.tar.gz |
|---|---|
| Size | 269.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20b4e95cc7695092b26d1df075d8f046dbd8707e1a86624b8f40df266ebc17c0
|
|
BLAKE2b-256 checksum How to use checksums |
dbc982b775481c6ceb5411e44c9acc140f7486479ab43da180779289ac66683b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.28.1
|
Release files / smellman_mbutil-0.3.10-py3-none-any.whl
| Download URL | smellman_mbutil-0.3.10-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
227cd196efdda59b8b064a708a83582709516ed65d9d7d97f8f1a0ba0444821c
|
|
BLAKE2b-256 checksum How to use checksums |
e861e8c34084dc12e9e3d9c058bb3f910617fde39711ef41a3d308dabbe28128
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.28.1
|
Security for smellman-mbutil 0.3.10
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.