skip to navigation
skip to content

umilandez 2.0.3.dev0

Landez is a python toolbox to manipulate map tiles.

Landez manipulates tiles, builds MBTiles, does tiles compositing and arrange tiles together into single images.

Tiles can either be obtained from a remote tile service URL, from a local Mapnik stylesheet, a WMS server or from MBTiles files.

For building MBTiles, Landez embeds mbutil from Mapbox at the final stage. The land covered is specified using a list of bounding boxes and zoom levels.


Landez is pure python and has no external dependency.

However, it requires mapnik if the tiles are rendered locally.

sudo aptitude install python-mapnik

And PIL to blend tiles together or export arranged tiles into images.

sudo aptitude install python-imaging


Building MBTiles files

Remote tiles

Using a remote tile service ( by default):

import logging
from landez import MBTilesBuilder


mb = MBTilesBuilder(cache=False)
mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0),
                zoomlevels=[0, 1])

Please respect Tile usage policies <>

Local rendering

Using mapnik to render tiles:

import logging
from landez import MBTilesBuilder


mb = MBTilesBuilder(stylefile="yourstyle.xml", filepath="dest.mbtiles")
mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0),
                zoomlevels=[0, 1])

From an other MBTiles file

import logging
from landez import MBTilesBuilder


mb = MBTilesBuilder(mbtiles_file="yourfile.mbtiles", filepath="dest.mbtiles")
mb.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0),
                zoomlevels=[0, 1])

From a WMS server

mb = MBTilesBuilder(wms_server="",

Blend tiles together

Merge multiple sources of tiles (URL, WMS, MBTiles, Mapnik stylesheet) together. (requires python PIL)

For example, build a new MBTiles by blending tiles of a MBTiles on top of OpenStreetMap tiles :

mb = MBTilesBuilder(filepath="merged.mbtiles")
overlay = TilesManager(mbtiles_file="carto.mbtiles")

Or composite a WMS layer with OpenStreetMap using transparency (40%):

mb = MBTilesBuilder(wms_server="",
overlay = TilesManager(remote=True)
mb.add_layer(overlay, 0.4)

Export Images

Assemble and arrange tiles together into a single image. (requires python PIL)

Specify tiles sources in the exact same way as for building MBTiles files.

import logging
from landez import ImageExporter


ie = ImageExporter(mbtiles_file="yourfile.mbtiles")
ie.export_image(bbox=(-180.0, -90.0, 180.0, 90.0), zoomlevel=3, imagepath="image.png")

Add post-processing filters

Convert map tiles to gray scale, more suitable for information overlay :

from landez.filters import GrayScale

ie = ImageExporter()

Replace a specific color by transparent pixels (i.e. color to alpha, a-la-Gimp) :

from landez.filters import ColorToAlpha

overlay = TileManager()
overlay.add_filter(ColorToAlpha('#ffffff'))  # white will be transparent

ie = ImageExporter()

Extract MBTiles content

from landez.reader import MBTilesReader

mbreader = MBTilesReader("yourfile.mbtiles")

# Metadata
print mbreader.metadata()

# Zoom levels
print mbreader.zoomlevels()

# Image tile
with open('tile.png', 'wb') as out:
    out.write(reader.tile(z, x, y))

# UTF-Grid tile
print reader.grid(z, x, y, 'callback')

Manipulate tiles

from landez import MBTilesBuilder

# From a TMS tile server
# tm = TilesManager(tiles_url="http://{s}{z}/{x}/{y}.png")

# From a MBTiles file
tm = TilesManager(mbtiles_file="yourfile.mbtiles")

tiles = tm.tileslist(bbox=(-180.0, -90.0, 180.0, 90.0),
                     zoomlevels=[0, 1])
for tile in tiles:
    tilecontent = tm.tile(tile)  # download, extract or take from cache



  • Lesser GNU Public License


2.0.3 (unreleased)

  • Nothing changed yet.

2.0.2 (2012-06-21)

  • Prevent the whole image to be converted to grayscale
  • Explicitly check http status code at tiles download

2.0.1 (2012-05-29)

  • Fix infinite loop on blending layers

2.0.0 (2012-05-25)

  • Rework cache mechanism
  • Jpeg tiles support (#14)
  • Remove use of temporary files
  • Image post-processing (#11)

2.0.0-alpha (2012-05-23)

  • Refactoring of whole stack

1.8.2 (2012-03-27)

  • Fix Mapnik rendering

1.8.1 (2012-02-24)

  • Fix MBTiles cache cleaning

1.8 (2012-02-24)

  • WMS support
  • Tiles compositing

1.7 (2012-02-17)

  • Catch Sqlite exceptions

1.6 (2012-02-08)

  • UTF-Grid support for MBTiles files

1.5 (2011-12-07)

  • Subdomain support for tiles servers
  • Low level tiles manipulation
  • Use i18n

1.4 (2011-10-17)

  • Remove extra logging message of mbutil

1.3 (2011-09-23)

  • Export set of tiles into single image

1.2 (2011-06-21)

  • Raise exception if no tiles in coverages

1.1 (2012-04-18)

  • Move internals to landez module
  • Split projection into separate module

1.0 (2011-04-18)

  • Initial working version
File Type Py Version Uploaded on Size
umilandez-2.0.3.dev0.tar.gz (md5) Source 2013-02-12 20KB