landez : introducing new features of our tiles toolbox

landez started as a very small toolbox to build MBTiles files specifying bounding boxes and zoom levels. We have been using it for several GIS projects at Makina Corpus, and can tell it's reliable !

Landez is pure python and follows the KISS principle. It has optional requirements on PIL and mapnik for compositing, tile arranging or rendering.

Recently, we've added many extra cool features, which deserve highlight !

Simple WMS support

With landez, you can store your WMS layers into MBTiles files ! It will request the WMS /images and save them into tiles on disk ! You can then enjoy the power of MBTiles files : transport, speed, ...

mb = MBTilesBuilder(wms_server="",

Tiles compositing

This is the killer feature ! With landez, you can now merge multiple sources of tiles (URL, WMS, MBTiles, Mapnik stylesheet) together !

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

mb = MBTilesBuilder(remote=True,
overlay = TilesManager(mbtiles_file="carto.mbtiles")

Simply make a composite a WMS layer with OpenStreetMap using transparency ! You might find this useful for compositing satellite image with street maps :

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

Arrange tiles into single /images

This feature can be very useful for printing tiled maps or have a quick overview of your compositing results !

Refer to any source of tiles, like you would do with MBTilesBuilder, add layers if you like and export the image !

ie = ImageExporter(tiles_url='http://server/tile/{z}/{x}/{y}.png')
ie.export_image(bbox=(-180.0, -90.0, 180.0, 90.0),

MBTiles content reading

landez can now read MBTiles content !

We could proudly add it to the list of implementations for the MBTiles spec and UTF-Grid spec !

Use MBTiles files like any tile source :

mb = MBTilesBuilder(mbtiles_file="yourfile.mbtiles")

...extract single image or UTF-Grid tiles :

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')

Next steps...

The code has grown quickly and deserves a good refactoring, which is being done in a separate branch on GitHub ! The goal is to keep the same simple API, better modularity, increase tests coverage...

If you are wiling to participate, feel welcome !

#python, #mapbox, #gis, #landez - Posted in the Dev category