12

I'm trying to merge 60 geotiff files into one huge file in order to be able to product tiles from that resulting huge geotiff file by using gdal2tiles.

The merge process worked, but for some reason it produces a file that has a size of 78GB instead of the expected 19GB. Not quite sure what went wrong there.

The reason for trying that is because tiling the 60 geotiffs one by one gives me white spaces on the map border.

3 Answers 3

16

Usually, GeoTIFFs are compressed for storage. Running gdal_merge on default settings won't compress the file. Add the option

-co COMPRESS=DEFLATE

(or any of the other options listed in the documentation) to your command to get smaller output files.

2
  • 1
    For future reference - mine, if nobody else's - gdal.org/frmt_gtiff.html has the set of GeoTiff specific options that you should be able to use for any of the gdal commands. Depending on the type of imagery you have, you might want COMPRESS=LZQ or even JPEG; it'd be well worth the time to verify the type of compression used on the source images.
    – Herb
    Commented Sep 26, 2010 at 1:42
  • Thanks Herb, I have updated the answer to contain your link.
    – underdark
    Commented Sep 26, 2010 at 12:14
5

As underdark points out, the best solution is to compress your imagery to prevent the large volume of empty space being stored directly (the native TIFF image is like a bitmap: every value takes up the same amount of space). Another handy compression option is:

-co COMPRESS=LZW

It rarely has the same compression ratio as DEFLATE, but has the advantage of working with most software, where DEFLATE isn't supported in many environments such as ArcGIS 9.x.

You can try even more aggressive lossless compression by using one of the wavelet transformations, such as ECW, MrSID or one of the various JPEG2000 implementations. Keep in mind that you'll need tools using GDAL or otherwise implement the libraries to access the data in these formats.

3

You might avoid merging your geotiff files by writing a vrt file which merge them "virtually".

It is an XML file that describe how the files should be assembled. All gdal utilities accept this vrt file as an input map. gdal2tiles or MapTiler are both based on gdal so that they should be able to use a vrt file (I haven't try yet with a vrt file but I have already tried with a gdal_wms file and it worked pretty good).

Writing the vrt file from scratch is not easy. Simply convert one of your geotiff to vrt to have an example:

gdal_tranlate -of vrt one_of_your_geotiff.tif one_of_your_geotiff.vrt

There is also a tool called gdalbuildvrt but I didn't try it.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.