2

I have 4 scenes of raster images that I need to merge. Average size of the scenes is only 60 MB, but the merged scene ended up at 6 GB in file size. Does anyone know why this happened?

  • 2
    Clarify: How did you merge them (what tool/algorithm)? What format were the source files in? What is the output format? How many bands/channels do the images have (RGB or more)? – Senshi May 29 '17 at 13:32
  • 1
    Are your scenes far apart each other? Empty pixels between the scenes take as much disk space as those which contain data if you do not use compression. Also if you use your GeoTIFFs only with QGIS and GDAL the "Sparse files" option may be good for you gdal.org/frmt_gtiff.html. Consider also using gdalbuildvrt gdal.org/gdalbuildvrt.html instead of writing scenes into a physical file. – user30184 May 29 '17 at 14:25
  • I used GDAL raster merge tool. The original format of the scenes are geoTIFF with single gray band. The scenes are adjacent to one another, no spaces between them. – Putraditama May 29 '17 at 15:47
  • Add gdalinfo about one source image and about the 6 GB result. – user30184 May 29 '17 at 16:45
5

Have you tried adding compression to the creation options, e.g.

gdal_merge.py input1.tif input2.tif -o output.tif -co 'COMPRESS=LZW' 
3

If you have RGB Files you can use JPEG Compression + YCBCR. Add the following to your gdal_merge command:

-co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR

If you have RGBA files (RGB + alpha channel) leave out the PHOTOMETRIC part

-co COMPRESS=JPEG 

if you don't have RGB images, you can use LZW Compression as suggested by dmci. ( + Use all CPUs for compression). Note: This has much worse performance than JPG Compression.

-co COMPRESS=LZW -co NUM_THREADS=ALL_CPUS

Additional information

For better view performance, use inner tiling, for faster merging add some I/O Cache.

Get some information regarding gdal_merge here and Geotiff format here


The command that I usually use is this one:

gdal_merge.py \
-of GTiff -ot Byte -o outfile.tif \
-co TILED=YES \
-co BLOCKXSIZE=512 \
-co BLOCKYSIZE=512 \
-co COMPRESS=JPEG \
-co PHOTOMETRIC=YCBCR \
--config GDAL_CACHEMAX 512 \
file1 file2 file3

At the End I use gdaladdo to add overviews for best performance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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