Alireza Kashian pisze: > Hi. > > One of the things I have been always looking for is the method for > enhancing PNG sizes made by mapnik. > Right now, each map tile (250x250px) is by average 90Kbyte (PNG-24bit) > in city centers..(where we have POIs, roads and other colorful features.). > > This file size is not suitable for web mapping. I checked google maps > and in those crowded areas, the size of PNGs are maximm 12Kbyte !!
It depends, what You are looking at. Here seems crowded: http://mapy.google.pl/?ie=UTF8&ll=52.247247,20.984488&spn=0.017053,0.045576&z=15 but there are really only few colors and details, so it will compress easily to 12-15KB. But if we move a little: http://mt2.google.com/mt/v=w2.92&hl=pl&x=9148&y=5393&z=14&s=Galil tile is 21kB due too few additional colors (and its gradients for anti-aliasing) and picture details. And finally: http://mapy.google.pl/?ie=UTF8&ll=50.732978,9.970093&spn=2.256443,5.83374&z=8 there are many details and colors so tiles are 30-40KB. What I noticed about google tiles, is that palettes have only 60-100 colors. Mapnik tries to use as much of 256 entries as possible. Here is comparison (in kB) of Google maps, Polish UMP map I'm rendering on my own and OSM map for about 50 tiles around center of Warsaw at each zoom: zoom Google UMP OSM 17 11,71 10,59 8,27 16 14,08 13,5 10,91 15 16,46 17,54 15,3 14 18,51 20,54 21,71 13 18,71 26,13 28,1 12 15,79 25,71 23,83 11 12,04 29,84 21,3 10 14,36 38,85 16,19 9 12,04 39,81 19,26 8 10,88 39,67 20,63 7 14,85 25,36 28,21 6 16,88 16,25 25,54 5 12,38 11,38 15,95 You can compare visual differences of all three maps here: http://mapa.ump.waw.pl/ump-www/index.html?zoom=14&lat=52.23184&lon=21.00579&layers=B00000T Use (+) in upper right to change layer and permalink url in lower right to check current zoom. "Google Ulice" is Google Street maps. As You can see i.e at zoom 12, Google has smallest tiles, but it's basically Yellow-Gray-White-Green boring map. UMP and OSM have many colors and details, so tiles are bigger. Also at UMP I enabled hillshading for whole Poland, so it also increases size, but mostly at zoom<11, when it is almost like white noise. At zoom>13 sizes are comparable and still google looks more boring then UMP or OSM (no icons and less colorful styles). > One way is to use PNG256 in mapnik. But since we use Tilecache for > generating the tiles, Metatile does not support PNG256 and if we turn > metatile off, then the we loose the texts on edges and even speed for > making tiles is much less. our maps are full screen, so 7x4=28 tiles per > view. For problem of missing texts on edges there is buffer_size attribute of map tag. Besides I use mod_tile, that supports metatiles: it cuts and saves each tile using mapnik's png256. I use 8x8 metatile + 128pix margin. > > I even made PNG256 with mapnik alone and still the size is around 25 to > 30Kbyte ...! comparing to gooogle, it is double or more.. > I used Photoshop "save for web" feature and chose Web Snap option in > save menue...the result PNG is like 9Kbyte !!! > Photoshop probably can reduce more colors and reduce randomness in color distribution, so it would compress better. In mapnik You can try reducing number of colors. In file include/mapnik/png_io.h, around line 204, change: octree<rgb> tree(256); to i.e.: octree<rgb> tree(100); This should reduce number of colors, size and quality in more colorful places. You could gain with this probably about 10%-20% of file size reduction. Also if You really need smaller tiles, reduce number of used colors in Your styles, use less complicated icons and reduce number of displayed objects per Zoom. There is trade off: colorful and detailed map or bigger files. What mapnik really lacks, is some api for passing options to writers. For starters quality compression for jpeg and number of colors in png256 or some switch for transparency support in png256 (off, binary, multilevel) that I'm experimenting now. > So I am still looking for possible Batch optimization of 600,000 PNGs > which are created by mapnik/tilecache. > > We usually update our maps every week and we need to find a solution for > that. > > Anyone has experience on methods and tips for enhancing the sizes? it is > a matter of giga bytes of transfer per day..... I update my map(http://mapa.ump.waw.pl/ump-www/) 2-3 times a week, ~380k tiles(most frequently viewed + some bigger areas of overview zooms). This is 2.4GB of data so average tile size is 6kB. Also I have enabled hillshading, that also increases size a bit (probably 10%). Of course it includes lots of almost empty tiles outside cities. It takes my 6 year old computer about 10h to redraw this set and because of metatiles in fact it generates 2x more tiles, than is send to cache server. Most of initial cache doesn't change so in practice thanks to rsync protocol there is only 150-250MB of data to transfer to external cache server (with 100Mbit internet access) . Regards, Marcin Rudowski _______________________________________________ Mapnik-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/mapnik-users

