Converts a Mapnik XML file into an MBTiles file.
This is used to generate tile overlays for maps, e.g. Google Maps for Android apps.
"Click to expand"
# Common dependencies
brew install gnu-sed mapnik boost-python3 py3cairo
# Python bindings for Mapnik
git clone --branch v3.0.x git@github.com:mapnik/python-mapnik.git
cd python-mapnik
gsed -i 's~{0}/include/pycairo~/usr/local/include/pycairo~g' setup.py
BOOST_PYTHON_LIB=boost_python39 PYCAIRO=true pip3 install .
# MBUtil dependency
git clone git://github.com/mapbox/mbutil.git
cd mbutil
pip3 install .
output=$project/app/src/main/assets/world.mbtiles
rm -i "$output"
cd mapnik2mbtiles
python3 generate_tiles_multiprocess.py mapfile.xml "$output" 4 4 --format webp
generate_tiles_multiprocess.py --help
usage: generate_tiles_multiprocess.py [options] input output 1..18 1..18
positional arguments:
input mapnik XML file
output a MBTiles file
1..18 minimum zoom level to render
1..18 maximum zoom level to render
optional arguments:
-h, --help show this help message and exit
--bbox f f f f bounding box that will be rendered
--threads THREADS # of rendering threads to spawn
--name NAME name for each renderer
--size SIZE resolution of the tile image
--format FORMAT format of the image tiles
--scheme SCHEME tiling scheme of the tiles
--no_compression disable MBTiles compression
--verbose
Feel free to send us feedback by submitting an issue. Bug reports, feature requests, patches, and well-wishes are always welcome.
Note: Pull requests are welcome. For major changes, please submit an issue first to discuss what you would like to change.
- https://github.com/mapnik/mapnik/wiki/aspect-fix-mode
- https://github.com/mapnik/mapnik/wiki/image-io
- https://github.com/mapnik/mapnik/wiki/mapnikrenderers
- https://maptiler.com/google-maps-coordinates-tile-bounds-projection/
- https://wiki.openstreetmap.org/wiki/slippy_map_tilenames
- https://wiki.openstreetmap.org/wiki/zoom_levels