[OSM-dev] NOT-saving empty Mapnik tiles

marqqs at gmx.eu marqqs at gmx.eu
Fri Aug 12 18:18:18 BST 2011


Hi,

I'm trying not to save empty tiles. Until now my approach is very simple but silly too:

The tile is rendered by Mapnik, then stored in a file.
After this, I look at the file's length and delete this file if the length does not exceed 116 bytes.

This is a lot of IO effort. Therefore I would like to determine if a tile is empty BEFORE it is going to be saved. This should be not too complicated in python... at least for someone who understands python. :-)

This is the code snippet:

      im = mapnik.Image(render_size, render_size)
      mapnik.render(mm, im)
      im.save(tile_name, 'png256')

Is there a function like im.is_empty() ?

Markus



More information about the dev mailing list