[mapserver-users] TIFF tiles and indexes

Eichner, Andreas - SID-NLK Andreas.Eichner at sid.sachsen.de
Tue May 6 03:45:39 EDT 2008


Hi Richard,

> The tile was originally a 24 bit JPEG, 5517 x 4889 pixels.

our tiles are RGB images, each 4000x4000 pixels in size. If 8bit mode
looks ugly you could use dithering but if you have the possibility you
might want to use Gimp or the like to manually create an indexed image
with an optimized palette.

> I was concerned about efficiency so I looked at tiles. I used 
> gdal_translate to convert the GIF into a tiled TIFF. This was followed

> by gdaladdo to produce overviews of 8x and 64x decimation.

The size for internal tiling defaults to 256x256 pixels. You might try
smaller sizes with the BLOCKXSIZE/BLOCKYSIZE creation option. Also, you
should probably add more overviews. MapServer always tries to scale
down. So if you have a zoom level lower than 8x MS loads and scales the
full resolution image which might be slow. Since overviews are created
offline you can safely select -r average for scaling and use the fast
nearest neighbor resampler for on-the-fly scaling at runtime.

> The TIFF file is now 29.3Meg.  This compares to the original JPEG of 
> 4.2Meg and the GIF of 14.2Meg.
> Also from what I've read, MapServer is meant to be faster with TIFFs 
> because decoding is easy.

That's right, the fastest thing you can get is an uncompressed TIFF as
long as your storage is fast enough. It's basically a tradeoff between
IO time and CPU time. If you have a fast hard drive you can save CPU
cycles by using an uncompressed TIFF but if you load your data from a
floppy you might want to load only as few as possible from it and use
CPU cycles for decompressing. 

> So, is it more efficient to use lots of individual TIFFs (indexed with

> gdaltindex) or just one big tiled TIFF?

As long as possible I would use a single file with internal overviews
and tiling since using external tiles always leads to an index scan,
filename loading and a open-load-close-cycle for every tile. So if you
zoom out MS has to load more and more tiles which is _much_ slower than
simply open a single file, select the best matching overview, load the
appropriate data portion (the internal tiles) and close the file. Note
that TIFFs can not get bigger than 4Gig as long as you have no
BigTIFF-support...

> If I choose individual files, what is a good rule of thumb for optimum

> tile size?

The optimum tile size depends on the raster size MS normally has to
serve. If the size is static you can create tiles in a size that MS has
to touch only 4 files in the worst case before switching to the next
overview layer...
You can go and make your tiles as large as possible (4Gig) but if your
data changes you have to do that again.

> Are there any good utilities for making raster sub-tiles?   Unless I 
> "can't see for looking", I can't see one in the GDAL utility list?

There's a python script "gdal_retile.py" in the GDAL suite.



More information about the mapserver-users mailing list