> On Nov 29, 2009, at 9:22 PM, Hemant Bist <[email protected]> wrote:
>
>> Hi,
>> Mapnik is correctly generating the tiles for me.
>> I am trying to figure out if Mapnik can tell me if the tile (or map
>> I generated) is empty(i.e. there is no information in the tile).

Mapnik does not have any way to report empty tiles. I think this is  
easiest just in python. In fact generate_tiles.py already does this  
when it prints "Empty Tile", see line 109-110:

http://trac.openstreetmap.org/browser/applications/rendering/mapnik/generate_tiles.py#L107

>> I have a sparse map with few polygons covering less than 50% of the
>> total map rendered.
>>
>> The empty tiles have small  size so that would be one heuristic. I
>> am hoping there is some better way:

Right, size/bytes/len is not exact because it will be dependent on the  
image encoding and tile size, which you might change, but I don't have  
any other ideas atm.

>> either Mapnik can tell me or may
>> there is some imagemagick or some other tool that can check that all
>> the pixels in the png are transparent(I am using transparent
>> background).

Despite the above mentioned limitation, calling len() is another option.

Maybe around line 89 
(http://trac.openstreetmap.org/browser/applications/rendering/mapnik/generate_tiles.py#L89
 
) you could do:

if len(im) == 116:
    ...then don't save tile....

As a quick check indicates that a 256x256 transparent tile (confirm  
for your system/build) is 116 when png256:

 >>> import mapnik
 >>> im = mapnik.Image(256,256)
 >>> im.background = mapnik.Color('transparent')
 >>> len(im.tostring('png256'))
116

Note: not tested...

>>
>> I am currently using generate_tiles.py.
>>
>> Would appreciate any pointers. In past I have benefited from
>> suggestion for workarounds  on this list, even if there is no direct
>> solution.
>>
>> Happy Holidays!
>> HB
> _______________________________________________
> Mapnik-users mailing list
> [email protected]
> https://lists.berlios.de/mailman/listinfo/mapnik-users

_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to