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.8.tar.gz (268.8 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.8-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for smellman_mbutil-0.3.8.tar.gz
Algorithm Hash digest
SHA256 3385be943e8c25c65f1b165101bd3830f893af93fdc47e3bc97a91973bb4644d
MD5 ed933f7531b278e554c63b4ce8bac859
BLAKE2b-256 aec38afb78b13fd3f41efaacea1c600b2e51b420438865d1f0d7569d4cc93c0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for smellman_mbutil-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b6ecffe7a4342295c86d7fae41da84c25cd008fc2d10fa9ddb666995df1914ac
MD5 1b6f2864636847b2720af11587bfb204
BLAKE2b-256 8af87519a865139ac510e6c17788cab78701b35218233bc5079e6b04f467249d

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