Skip to main content

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.

CI PyPI version

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

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

smellman_mbutil-0.3.9.tar.gz (269.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smellman_mbutil-0.3.9-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file smellman_mbutil-0.3.9.tar.gz.

File metadata

  • Download URL: smellman_mbutil-0.3.9.tar.gz
  • Upload date:
  • Size: 269.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for smellman_mbutil-0.3.9.tar.gz
Algorithm Hash digest
SHA256 42c49acebbbee0e12bc4aab757a9ac36ec4b7e4e7b17c0b2db28072965927e65
MD5 f108b9cac9d7b6cde67a8a0268b82f62
BLAKE2b-256 9a7d18e4a4f754fc2f51a0753a0fb1290024c706bcf38e8e589f75996b0326f9

See more details on using hashes here.

File details

Details for the file smellman_mbutil-0.3.9-py3-none-any.whl.

File metadata

File hashes

Hashes for smellman_mbutil-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 2684ec6fc8c70dfd8102079a80be7f93bedb451bfd02534e11125016d0da6c8f
MD5 6075a4aa332736bff70074a68e273a1f
BLAKE2b-256 8540e31262503747776c25468d03cbee76239f59fd8f0952e9474ae49fd59998

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