[gdal-dev] GDAL performance compared with libtiff

Even Rouault even.rouault at spatialys.com
Fri Aug 7 11:25:28 PDT 2015


Le jeudi 06 août 2015 17:29:06, Immanuel Weber a écrit :
> Hi all,
> 
> I'm working on an application where lots of images have to be written.
> Until now I'm using libtiff for that task. But as I want to add
> georeferencing and the like I'm having a look at GDAL right now. I did a
> quick evaluation of its performance related to libtiff and unfortunately
> it has quite a lot of overhead. I first tested GDAL 1.10 and it was a
> factor of 6-7 slower than the direct write with libtiff. With GDAL 2.0 it
> got a little better with a factor of 4. (I took a 1,5 MP image and wrote
> for a few hundred times to the disk and libtiff takes about 3 ms for that,
> where as GDAL around 12 ms). I read about a performance issue with
> GDALDataSet::RasterIO vs GDALRasterBand::ReadBlock and tried to implement
> the storage using GDALRasterBand::WriteBlock* but that almost took more
> time than the GDALDataSet::RasterIO version.
> 
> Is there any other way to write tiffs quickly with GDAL, or is that kind of
> overhead expected for the added functionality?

Immanuel,

WriteBlock() with a INTERLEAVE=BAND file should be really close to pure libtiff 
performance. Other cases will involve a few extra buffer copies.

Another option is to write the imagery with libtiff as you did, and then open 
the file in update mode with GDAL to add the georeferencing. This will just 
rewrite the TIFF header.

> 
> Thanks and best regards,
> Immanuel
> 
> *I wasn't really successful in doing that, because I didn't find a way to
> write pixel interleaved images with that

GDAL blocks are per band. But GDAL will take care of combining several blocks 
of same (x,y) for a INTERLEAVE=PIXEL TIFF. To get the best performance, in 
INTERLEAVE=PIXEL, you should do (pseudo-code):

for y in yblocks:
	for x in xblocs:
		for b in bands:
			GetRasterBand(b)->WriteBlock(x,y, buffer)

to avoid partial TIFF tiles/strips to be written, read and re-written when the 
data for the band comes.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list