<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Dec 30, 2010, at 6:18 AM, Vincent Schut wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On 12/30/2010 12:07 PM, Even Rouault wrote:<br><blockquote type="cite">Le jeudi 30 décembre 2010 11:52:34, Vincent Schut a écrit :<br></blockquote><blockquote type="cite"><blockquote type="cite">Hi all,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Kind of a corner case, but i was hoping that gdal_translate's -expand<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">option (to expand colorindexed 1-band files into 3-band rgb files) would<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">also copy and expand the overviews when run with the (geotiff specific,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">I know) create option "-co COPY_SRC_OVERVIEWS=YES". It appears to not do<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">so, and just discards the overviews. Would this be a bug, or maybe a<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">feature to add?<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">When you use -expand, an intermediate VRT file is created to do the color<br></blockquote><blockquote type="cite">expension, but it doesn't retain the source overviews, so when the GeoTIFF<br></blockquote><blockquote type="cite">driver copies the VRT into the final TIFF, there are no more source overviews<br></blockquote><blockquote type="cite">from its point of view. "-co COPY_SRC_OVERVIEWS=YES" will only work if no<br></blockquote><blockquote type="cite">intermediate VRT is used, so basically when you don't use any gdal_translate<br></blockquote><blockquote type="cite">options, except creation options of the target driver.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Use case: for a classified, indexed image, I have built overviews using<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">the 'mode' operator, which is obviously the most usefull for this kind<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">of image, and only applicable on 1-band indexed data. I want to have a<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">rgb version of this, but with those overviews, so the overviews should<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">be an rgb version of the 'mode' overviews of the original. It is<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">impossible to create the same overviews once the image has been expanded<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">into rgb; mode will result in wrong, and sometimes even weird results (I<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">presume mode works band-wise),<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">yes, mode works band per band<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite">and average and partners will result in<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">colors that are not defined in the original colorindex (which I want to<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">avoid, we are talking maps and legends here).<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">I think I can work around this by creating a separate file for each<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">overview level (bla.ovr, bla.ovr.ovr, and so on), expanding those, and<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">than using copy_src_overviews to create one file with internal overviews<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">again, but this feels kind of awkward, and the above seemed so elegant...<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">yes that's a plausible way of proceeding. Making what you wish work would<br></blockquote><blockquote type="cite">require :<br></blockquote><blockquote type="cite">1) add support for using/exposing source overviews in the VRT<br></blockquote><blockquote type="cite">2) add support for doing color expansion on overviews of the VRT<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">which I feel would be rather complicated to implement<br></blockquote><br>Which I understand. I didn't know it worked through vrt, though now that sounds very plausible.<br>I'll script my workaround, no problem.<br></div></blockquote><div><br></div><div><br></div><div>The Ossim utility ossim-icp has a&nbsp;<span class="Apple-style-span" style="font-family: monospace; white-space: pre; "> --res-level  option that will extract an overview level from a file</span></div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre; ">something similar might be a useful addition </span><span class="Apple-style-span" style="font-family: monospace; white-space: pre; ">to gdal functionality</span></div><div><font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space: pre;"><br></span></font></div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre; "><br></span></div><div><font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space: pre;">pseudo code</span></font></div><div><font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space: pre;"><br></span></font></div><div><font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space: pre;">for level in overviews</span></font></div><div><font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space: pre;">  ossim-icp -r level tiff_tiled  $SRC tmp$SRC_%level</span></font></div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre; ">  gdal_translate -expand tmp$SRC_%level $SRC_%level</span></div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre; ">  ?? how best to recombine overviews ?? </span></div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre; "><br></span></div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre; ">I don't know how best to do step 3</span></div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre; "><br></span></div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre; ">Cheers</span></div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre; "><br></span></div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre; ">Norman</span></div><div>&nbsp;</div></div></body></html>