An importer and exporter for MBTiles
Project description
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)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smellman_mbutil-0.3.10.tar.gz.
File metadata
- Download URL: smellman_mbutil-0.3.10.tar.gz
- Upload date:
- Size: 269.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20b4e95cc7695092b26d1df075d8f046dbd8707e1a86624b8f40df266ebc17c0
|
|
| MD5 |
8c75c1c1dad102f69e722f4f25ebaf40
|
|
| BLAKE2b-256 |
dbc982b775481c6ceb5411e44c9acc140f7486479ab43da180779289ac66683b
|
File details
Details for the file smellman_mbutil-0.3.10-py3-none-any.whl.
File metadata
- Download URL: smellman_mbutil-0.3.10-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
227cd196efdda59b8b064a708a83582709516ed65d9d7d97f8f1a0ba0444821c
|
|
| MD5 |
d994c8112fef2e14b126d6c7efae5aa8
|
|
| BLAKE2b-256 |
e861e8c34084dc12e9e3d9c058bb3f910617fde39711ef41a3d308dabbe28128
|