I'm trying to compress my 1.2GB DEM file to reduce its size through the OSGeo4W Shell, but it's not working, as the command only works for RGB images (3 bands), but my DEM only has 1 band (1-band).

I tried the command:

for %i in (*.tif) do gdal_translate -of GTiff -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR -co TILED=YES %i %~ni_ok.tif

Error message:

enter image description here

edit: 1st message error:

ERROR6:PHOTOMETRIC=YCBCR not supprted on a 1-band raster: only compatible of a 3-band <RGB> raster

I tried the answer from @bugmenot123:

for %i in (*.tif) do gdal_translate -of GTiff -co COMPRESS=DEFLATE-co PREDICTOR=2 -co TILED=YES %i %~ni_ok.tif

but new error message:

Usage: gdal_translate [--help-general] [--long-usage]
       [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/
             CInt16/CInt32/CFloat32/CFloat64}] [-strict]
       [-of format] [-b band] [-mask band] [-expand {gray|rgb|rgba}]
       [-outsize xsize[%]|0 ysize[%]|0] [-tr xres yres]
       [-r {nearest,bilinear,cubic,cubicspline,lanczos,average,mode}]
       [-unscale] [-scale[_bn] [src_min src_max [dst_min dst_max]]]* [-exponent[_bn] exp_val]*
       [-srcwin xoff yoff xsize ysize] [-epo] [-eco]
       [-projwin ulx uly lrx lry] [-projwin_srs srs_def]
       [-a_srs srs_def] [-a_ullr ulx uly lrx lry] [-a_nodata value]
       [-a_scale value] [-a_offset value]
       [-nogcp] [-gcp pixel line easting northing [elevation]]*
       |-colorinterp{_bn} {red|green|blue|alpha|gray|undefined}]
       |-colorinterp {red|green|blue|alpha|gray|undefined},...]
       [-mo "META-TAG=VALUE"]* [-q] [-sds]
       [-co "NAME=VALUE"]* [-stats] [-norat]
       [-oo NAME=VALUE]*
       src_dataset dst_dataset
  • 1
    The error message says it. Don't use photometric=ycbcr.
    – user30184
    Jun 3, 2021 at 5:35
  • Please place error messages in the body of the Question as text. Images are not legible on all platforms, and can't be searched by others with the same issue.
    – Vince
    Jun 3, 2021 at 11:22
  • Ok @Vince, i maked update issue Jun 3, 2021 at 21:06
  • 1
    You are missing a space between DEFLATE and -co, that was my fault, sorry. Jun 4, 2021 at 23:02

2 Answers 2


You most probably do not want to compress DEM data with JPEG, that would be lossy and introduce weird steps in the data.

Instead I recommend the DEFLATE compression. To improve the size savings you can also use a predictor for the compressor. See https://gdal.org/drivers/raster/gtiff.html for details and more options.

for %i in (*.tif) do gdal_translate -of GTiff -co COMPRESS=DEFLATE -co PREDICTOR=2 -co TILED=YES %i %~ni_ok.tif

If your data is floating point values, use PREDICTOR=3.

  • 1
    This is amazing, I managed to reduce a 1.2GB DEM ALOS PALSAR to just 88MB without loss of pixel information. I will run this DEM on SAG-GIS to compare the results, Thanks!!! Jun 4, 2021 at 23:27

You really shouldn't use the lossy JPEG algorithm for compression of DEM data.

Get more info here: https://kokoalberti.com/articles/geotiff-compression-optimization-guide/

You could increase processing speed with GDAL creation options (i.e. NUM_THREADS, GDAL_CACHEMAX)

Your Answer

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

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