[gdal-dev] gdal_translate -expand rgb incompatible with geotiff COPY_SRC_OVERVIEWS

Vincent Schut schut at sarvision.nl
Thu Dec 30 06:18:32 EST 2010


On 12/30/2010 12:07 PM, Even Rouault wrote:
> Le jeudi 30 décembre 2010 11:52:34, Vincent Schut a écrit :
>> Hi all,
>>
>> Kind of a corner case, but i was hoping that gdal_translate's -expand
>> option (to expand colorindexed 1-band files into 3-band rgb files) would
>> also copy and expand the overviews when run with the (geotiff specific,
>> I know) create option "-co COPY_SRC_OVERVIEWS=YES". It appears to not do
>> so, and just discards the overviews. Would this be a bug, or maybe a
>> feature to add?
>
> When you use -expand, an intermediate VRT file is created to do the color
> expension, but it doesn't retain the source overviews, so when the GeoTIFF
> driver copies the VRT into the final TIFF, there are no more source overviews
> from its point of view. "-co COPY_SRC_OVERVIEWS=YES" will only work if no
> intermediate VRT is used, so basically when you don't use any gdal_translate
> options, except creation options of the target driver.
>
>>
>> Use case: for a classified, indexed image, I have built overviews using
>> the 'mode' operator, which is obviously the most usefull for this kind
>> of image, and only applicable on 1-band indexed data. I want to have a
>> rgb version of this, but with those overviews, so the overviews should
>> be an rgb version of the 'mode' overviews of the original. It is
>> impossible to create the same overviews once the image has been expanded
>> into rgb; mode will result in wrong, and sometimes even weird results (I
>> presume mode works band-wise),
>
> yes, mode works band per band
>
>> and average and partners will result in
>> colors that are not defined in the original colorindex (which I want to
>> avoid, we are talking maps and legends here).
>>
>> I think I can work around this by creating a separate file for each
>> overview level (bla.ovr, bla.ovr.ovr, and so on), expanding those, and
>> than using copy_src_overviews to create one file with internal overviews
>> again, but this feels kind of awkward, and the above seemed so elegant...
>
> yes that's a plausible way of proceeding. Making what you wish work would
> require :
> 1) add support for using/exposing source overviews in the VRT
> 2) add support for doing color expansion on overviews of the VRT
>
> which I feel would be rather complicated to implement

Which I understand. I didn't know it worked through vrt, though now that 
sounds very plausible.
I'll script my workaround, no problem.

Thanks for the info.

Vincent.
>
>>
>> Vincent.
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list