<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">Le 06/10/2022 à 07:55, thomas bonfort a
      écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:CAOM3y2igs=64FUS5vZx-LcQQO2hy_CBoeHhTnK6EKy+XMdk+9Q@mail.gmail.com">
      <div dir="auto">
        <div>There are only very specific cases where it would be valid
          to directly copy overview tiles, namely if both image sizes
          are an exact power of 2. I'll let Even contradict me if I'm
          wrong, but I highly doubt that what you are trying to do is
          possible.</div>
      </div>
    </blockquote>
    <p>If your input files have the same overview levels and resolution,
      gdalbuildvrt should already build a VRT with the
      <OverviewList> element listing those overview levels</p>
    <p>Demo with a file from GDAL autotest suite<br>
    </p>
    <p>$ gdal_translate autotest/gdrivers/data/small_world.tif left.tif
      -srcwin 0 0 200 200 -outsize 1024 0 -of COG<br>
      $ gdal_translate autotest/gdrivers/data/small_world.tif right.tif
      -srcwin 200 0 200 200 -outsize 1024 0 -of COG<br>
      $ gdalbuildvrt out.vrt left.tif right.tif<br>
      $ grep Overview out.vrt<br>
        <OverviewList resampling="nearest">2</OverviewList><br>
      $ gdalinfo out.vrt | grep Overview<br>
        Overviews: 1024x512<br>
    </p>
    <p>and that should be useable by the COG driver with -co
      OVERVIEWS=FORCE_USE_EXISTING</p>
    <p>Note however that the overview exposed by the VRT is a virtual
      overview: so in the general case, there's no guarantee that the
      values of the pixel exactly match those of the source overview,
      depending on the spatial registration of each VRT source. If you
      have a nice mosaic of adjacent sources with power-of-2 dimensions,
      then yes, you're in the good situation.<br>
    </p>
    <p>But, if you were to produce a JPEG-compressed COG, don't expect
      *lossless* copy of overviews in the case of JPEG compression for
      target overviews: GDAL will get the decompressed values of the
      JPEG compressed overviews of the sources and would re-compress
      them. In the above mentioned perfect case, that could potentially
      be implemented (like "gdal_translate input.jpeg output.tif -co
      COMPRESS=JPEG" does currently), but it isn't and it would be a
      very specific non-trivial code to write.<br>
    </p>
    <p>Even<br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite"
cite="mid:CAOM3y2igs=64FUS5vZx-LcQQO2hy_CBoeHhTnK6EKy+XMdk+9Q@mail.gmail.com">
      <div dir="auto">
        <div dir="auto">regards,</div>
        <div dir="auto">Thomas<br>
          <br>
          <div class="gmail_quote" dir="auto">
            <div dir="ltr" class="gmail_attr">Le jeu. 6 oct. 2022,
              05:58, Ian Reese <<a href="mailto:xycarto@gmail.com"
                moz-do-not-send="true" class="moz-txt-link-freetext">xycarto@gmail.com</a>>
              a écrit :<br>
            </div>
            <blockquote class="gmail_quote">
              <div dir="ltr">
                <div class="gmail_default">Hi GDAL,</div>
                <div class="gmail_default"><br>
                </div>
                <div class="gmail_default">Let's say I have two GTiff
                  files in COG format:</div>
                <div class="gmail_default"><br>
                </div>
                <div class="gmail_default">f1.tif</div>
                <div class="gmail_default">f2.tif</div>
                <div class="gmail_default"><br>
                </div>
                <div class="gmail_default">f1.tif and f2.tif are created
                  like so:</div>
                <div class="gmail_default"><br>
                </div>
                <div class="gmail_default">
                  <table>
                    <tbody>
                      <tr>
                        <td id="m_-3397547538372092727gmail-LC15">gdal_translate
                          input.tif <span>f1.tif</span> \</td>
                      </tr>
                      <tr>
                      </tr>
                    </tbody>
                  </table>
                  <table>
                    <tbody>
                      <tr>
                        <td id="m_-3397547538372092727gmail-LC16">-of
                          COG \</td>
                      </tr>
                      <tr>
                      </tr>
                    </tbody>
                  </table>
                  <table>
                    <tbody>
                      <tr>
                        <td id="m_-3397547538372092727gmail-LC17"> -co
                          BLOCKSIZE=256 \</td>
                      </tr>
                      <tr>
                      </tr>
                    </tbody>
                  </table>
                  -co COMPRESS=JPEG \</div>
                <div class="gmail_default"><br>
                </div>
                <div class="gmail_default">I can easily create a vrt of
                  these two COGs and get the expected behaviour where
                  the VRT honours the overviews of the f1 and f2 COGs.</div>
                <div class="gmail_default"><br>
                </div>
                <div class="gmail_default">gdalbuildvrt cog.vrt f1.tif
                  f2.tif</div>
                <div class="gmail_default"><br>
                </div>
                <div class="gmail_default">This is my question, is it
                  possible to create a COG Tif from this VRT that copies
                  over the overviews from each COG in the VRT?</div>
                <div class="gmail_default"><br>
                </div>
                <div class="gmail_default">For example something like:<br>
                  <br>
                </div>
                <div class="gmail_default">gdal_translate cog.vrt
                  cog.tif -of COG -co OVERVIEWS=FORCE_USE_EXISTING</div>
                <div class="gmail_default"><br>
                </div>
                <div class="gmail_default">I suspect this may not be
                  possible. My guess is that translate is confused by
                  which overviews to use when creating the single
                  cog.tif? Or that when I created f1.tif and f2.tif I
                  missed a setting?</div>
                <div class="gmail_default"><br>
                </div>
                <div class="gmail_default">I have tried many
                  combinations to get this to work, but I think it might
                  be time to ask the experts. Any insight to this would
                  be greatly appreciated.</div>
                <div class="gmail_default"><br>
                </div>
                <div class="gmail_default">Cheer,</div>
                <div class="gmail_default"><br>
                </div>
                <div class="gmail_default">Ianto<br>
                </div>
                <div class="gmail_default">
                  <div>
                    <div><span></span></div>
                  </div>
                </div>
                <br>
                -- <br>
                <div dir="ltr" data-smartmail="gmail_signature">
                  <div dir="ltr">
                    <div>Ian C Reese</div>
                    <div><a href="https://xycarto.com" target="_blank"
                        rel="noreferrer" moz-do-not-send="true"
                        class="moz-txt-link-freetext">https://xycarto.com</a><br>
                    </div>
                  </div>
                </div>
              </div>
              _______________________________________________<br>
              gdal-dev mailing list<br>
              <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank"
                rel="noreferrer" moz-do-not-send="true"
                class="moz-txt-link-freetext">gdal-dev@lists.osgeo.org</a><br>
              <a
                href="https://lists.osgeo.org/mailman/listinfo/gdal-dev"
                rel="noreferrer noreferrer" target="_blank"
                moz-do-not-send="true" class="moz-txt-link-freetext">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
            </blockquote>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </body>
</html>