gdal icon indicating copy to clipboard operation
gdal copied to clipboard

Simplify passing options to `gdal raster overview add` ?

Open dbaston opened this issue 7 months ago • 1 comments

Feature description

I'm looking at an example from https://blog.cleverelephant.ca/2015/02/geotiff-compression-for-dummies.html, where we first convert a raster:

gdal_translate \
  -b 1 -b 2 -b 3 \
  -co COMPRESS=JPEG \
  -co JPEG_QUALITY=50 \
  -co PHOTOMETRIC=YCBCR \
  -co TILED=YES \
  5255C.tif 5255C_JPEG_YCBCR_50.tif

and then add overviews

gdaladdo \
  --config COMPRESS_OVERVIEW JPEG \
  --config JPEG_QUALITY_OVERVIEW 50 \
  --config PHOTOMETRIC_OVERVIEW YCBCR \
  --config INTERLEAVE_OVERVIEW PIXEL \
  -r average \
  5255C_JPEG_YCBCR_50.tif \
  2 4 8 16

As far as I can see, this is best replaced in the new CLI by

gdal raster pipeline ! \
  read 5255C.tif ! \
  select 1 2 3 ! \
  write 5255C_JPEG_YCBCR_50.tif \ 
  --co COMPRESS=JPEG \
  --co JPEG_QUALITY=50 \
  --co PHOTOMETRIC=YCBCR \
  --co TILED=YES

gdal raster overview add \
   5255C_JPEG_YCBCR_50.tif \
  --config COMPRESS_OVERVIEW JPEG \
  --config JPEG_QUALITY_OVERVIEW 50 \
  --config PHOTOMETRIC_OVERVIEW YCBCR \
  --config INTERLEAVE_OVERVIEW PIXEL \
   --levels 2,4,8,16

As a developer I understand why we are using --co in one case and --config in the other, but I'm not sure it's terribly obvious to a user. If we are creating an overview, should creation option --co COMPRESS=JPEG be understood to apply to that overview? In this case it makes sense, but I'm not sure blurring the lines between creation and configuration options, as a general practice, would actually reduce confusion.

Additional context

No response

dbaston avatar May 22 '25 17:05 dbaston

Small remark: in both gdaladdo and gdal raster overview add case, in your above scenario, none of the config options should be necessary as the GeoTIFF driver will use by default the settings from the full resolution dataset

rouault avatar May 22 '25 18:05 rouault

implemented in https://github.com/OSGeo/gdal/pull/13042

rouault avatar Sep 07 '25 17:09 rouault