GDAL – Efficient Downsampling with GDAL

demgdalgdal-translategdalwarp

I have a 350go GeoTIFF file with DEM data for the entire world. (a mix of SRTM, EUDEM, etc. …)

This TIFF file is tiled with a block size of 256*256.

I would like to downsample this file to a lower resolution (original file resolution is 1295829, 464402)

I tried with this command:

gdal_translate -co NUM_THREADS=ALL_CPUS -r nearest -co BIGTIFF=YES -co 
COMPRESS=LZW -outsize 0.1% 0.1% -co BLOCKXSIZE=256 -co BLOCKYSIZE=256 -co 
TILED=YES world.tif downsized_world.tif

The output file resolution should be close to 1295 * 464

The problem is that it seems like it will take forever to complete (progress bar stuck at 0 for few hours) do you have any idea on how I could resample this file faster?

Resampling the file with an even lower resolution does not seem to make it go faster when for me it should be, isn't it? (Fewer pixels to read = faster resample?)

Best Answer

Try gdalwarp, it can utilize multithreading and might be more efficiant than gdal_translate for this kind of tasks:

gdalwarp -r average -ts 1295 464 \ 
    -wm 2048 -multi -wo NUM_THREADS=ALL_CPUS \
    -co BLOCKXSIZE=256 -co BLOCKYSIZE=256 -co TILED=YES \
    -co NUM_THREADS=ALL_CPUS -co COMPRESS=LZW \
    world.tif downsized_world.tif

Although average will be slower, nearest Interpolation is not suitable to be used with DEM data.

Change the used memory to fit your system, it's this option: -wm 2048.

Related Question