[mapserver-users] geotiff raster optimization

Javier Infante jabi at irontec.com
Wed May 28 09:27:49 EDT 2008


Hi List!

First of all, i would like to tell I'm a newbie with these issues, and
hardy understand everysingle concept involving geo-references and
projections and stuff like that. I have been using mapserver for about a
month, but right now i'm stuck with some optimization issues i am about
to explain.

I'm building a map based in images i generate from scratch. Let's say i
have one picture per country. Those pictures are based in a huge png
file 10000x14660 pixels. So lets say i have my own projection system.

I have isolated every single country in the world in its own image file,
and i have managed to get the xmin, xmax ymin ymax coords for every
country.

The size of each country depends on a few concepts which would be long
to explain... but every country will have a different size. Alltought
mapserver manages that correctly. Here's an example of a file * in my
png images directory:

TR.png:  PNG image data, 1200 x 400, 8-bit colormap, non-interlaced
TT.png:  PNG image data, 1400 x 1400, 8-bit colormap, non-interlaced
TW.png:  PNG image data, 1200 x 1000, 8-bit colormap, non-interlaced
TZ.png:  PNG image data, 800 x 800, 8-bit colormap, non-interlaced
UA.png:  PNG image data, 1000 x 600, 8-bit colormap, non-interlaced
UG.png:  PNG image data, 400 x 400, 8-bit colormap, non-interlaced
US.png:  PNG image data, 5800 x 3800, 8-bit colormap, non-interlaced
UY.png:  PNG image data, 400 x 400, 8-bit colormap, non-interlaced
UZ.png:  PNG image data, 2400 x 1400, 8-bit colormap, non-interlaced
(so you got the idea right?)
The total size of the pngs is 50 MB (but expected to be much bigger).

So for every image of each country i do this procedure:

[*] pngquant, so i downsample my PHP-GD generated 24 RGB PNGs to 8
colormaps with a real acceptable quality.
(i have had some trouble with the color i used as a background (and
later defined as OFFSITE), because pngquant changed it. pure white
(#FFF) seems to work fine later).
I think this step is useless, because later, i make mapserver generate
the image as a jpeg... or it isn't??

[*] gdal_translate -of GTIFF -co TILED=YES -a_ullr xmin ymax ymin xmax
my.png new.tiff
which from what i have understood, uncompress all the image data (nice
to mapserver) and also puts those extend variables inside the image
file.
 
[*] gdaladdo -r nearest file.tiff 2 4 8 16 32 64 128 1000
which i think puts "thumbnails" of the huge picture, inside it. So
mapserver access to less amount of data when the zoom is not far enough.


Then, with all my tiff files, i run the following command:
gdaltindex world.shp *tiff

which generates world.shx world.shp and world.dbf.

The size of all the generated tiffs is around 500MB (which is not much
for mapserver right?)


my .map file looks like this:

MAP
        NAME "World"
        SIZE 750 550
        IMAGECOLOR 83 83 83
        IMAGETYPE png24
        EXTENT -10000 -7330 10000 7330
        OUTPUTFORMAT
        NAME png24
                DRIVER "GD/PNG24"
                MIMETYPE "image/png"
        IMAGEMODE RGB
        EXTENSION "png"
        END
LAYER
        STATUS DEFAULT
        TYPE RASTER
        NAME "MUNDO"
        TILEINDEX "world.shp"
        OFFSITE 255 255 255
END
END

As a frontend I use openlayers, so I actually think the imagetype and
output format get overwritten by the openlayers software, which adds to
every request to the cgi the imagetype=png variable, so I'm pretty sure
the images that are generated by mapserver, are jpegs (smaller size than
png and png24, and really acceptable quality).


The main problem of the system is performance. It takes about 40 secs to
generate the first level of zoom in the openlayers front-end (and about
the same time, every time you zoom in).

If it's usefull, i have compiled a 5.0.2 version of mapserver with this
configure options:
./configure --with-gdal  --with-fastcgi --with-png12 --with-gd

I have develped a cache system (PHP based), which simply acts as a proxy
for mapserver. I guess i could use tilecache or geowebcache... but the
idea of the system, is to be running permanently: every country will be
regenerated with a new picture every few minutes (so i guess a cache
system woudln't do the trick...).

So thanks for reading this far, and i would really appreciate if someone
could give me some light.

thank you for reading this far ;)

-- 
Javier Infante <jabi at irontec.com>
Irontec



More information about the mapserver-users mailing list