This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How to force mapnik render only not empty tiles?

1

Is there a way to force mapnik not to generate empty tiles? And create instead a symbolic link for that???

Update

Sorry for DUMM question. So how to do that generate_tiles.py will not save empty tiles?

This question is marked "community wiki".

asked 06 Nov '11, 07:54

Gevork's gravatar image

Gevork
234121422
accept rate: 0%

wikified 23 Nov '11, 12:49


3 Answers:

4

I don't have a direct answer, but in practice I add a command at the end of the generation for removing these empty tiles: find tiles/ -size 116c | xargs rm

answered 06 Nov '11, 21:48

NicolasDumoulin's gravatar image

NicolasDumoulin
3.3k42256
accept rate: 13%

@NicolasDumoulin do you add this line in the end of generate_tiles.py ????

(06 Nov '11, 22:13) Gevork

Well, no, it is a bash command (linux). But I think you can achieve the same in pure python as follow:

import os,glob;

for f in glob.glob('tiles/**/*'): if (os.path.getsize(f) == 0): os.remove(f)

(07 Nov '11, 08:15) NicolasDumoulin

@NicolasDumoulin when I make find tiles/ -size 116c | xargs rm I get rm: missing operand

here is the output marmur@marmur-Extensa-5635ZG:~/tiles$ find yerevanMap/ -size 116c | xargs rm rm: missing operand Try `rm --help' for more information. marmur@marmur-Extensa-5635ZG:~/tiles$

Any idea why???

(23 Nov '11, 18:45) Gevork

I think it is because the result of the command find is empty, you can check it by removing "| xargs rm" from the command. Maybe the size value isn't correct. I've found the "116" by looking at the printed size of my empty tiles with the "ls -l" command.

(23 Nov '11, 20:09) NicolasDumoulin

@NicolasDumoulin -rw-rw-r-- 1 marmur marmur 139 2011-11-23 00:51 0.png I get this... so should it be -size 139c???

(23 Nov '11, 22:41) Gevork

@NicolasDumoulin thanks! it worked, found out that empty tiles was not 139 but 103 by me.... deleted like a charm! once again, thank you very much

(23 Nov '11, 22:57) Gevork

be aware that empty sea tile, empty land tile, or any other "empty" tile that has only one color in it, may all have exactly the same size.

(09 Jul '14, 22:45) leding
showing 5 of 7 show 2 more comments

3

Mapnik doesn't generate tiles; Mapnik is a library only. It is the program that calls Mapnik - e.g. generate_tiles.py or renderd or tirex or something else - that generates tiles, or maybe metatiles. Mapnik has no way of signalling to these calling programs that it has just generated an "empty" tile (anyway, in our standard OSM style, only sea tiles are really "empty", everything else has at least a land polygon drawn).

Read the thread Not saving empty Mapnik tiles on the osm-dev mailing list for more information.

answered 06 Nov '11, 10:06

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

0

I don't think that "only sea tiles are really empty" - in some cases it depends of network connection when Mapnik receives "empty" blue tiles.

answered 07 Jun '13, 13:41

nedol's gravatar image

nedol
1
accept rate: 0%

Source code available on GitHub .