Skip to content

A Python script used to generate tile overlays for maps, e.g. Google Maps for Android apps.

Notifications You must be signed in to change notification settings

1951FDG/mapnik2mbtiles

Repository files navigation

mapnik2mbtiles

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.

Table of Contents

"Click to expand"

Installation

macOS - Python 3.9

# 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 .

Usage

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

Feedback

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.

Documentation

Credits

Built with

Attributions

Acknowledgments

Special thanks to MapBox for the MBTiles file format.

About

A Python script used to generate tile overlays for maps, e.g. Google Maps for Android apps.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published