<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Thank you all for your answers. As andy already pointed out, this
      behavior is due to the fact that <br>
      openjpeg is not utilizing markers yet when reading JPEG2000 files.<br>
      This issue seems to confirm that:
      <a class="moz-txt-link-freetext" href="https://github.com/uclouvain/openjpeg/issues/944">https://github.com/uclouvain/openjpeg/issues/944</a></p>
    <p>So I tried the JP2ECW-ERDAS driver again with a current ECW
      version 5.5 (3.x does not seem to utilize TLMs either), which led
      to the desired result.<br>
      This way, the number of requests can be significantly reduced (~6
      for one tile).<br>
      Still a lot but sufficient for my use case.<br>
    </p>
    <p>I actually wanted to give kakadu a try too but unfortunately the
      source code is needed to build it with gdal (which is not included
      in the demo).</p>
    <p>- Martin<br>
    </p>
    <div class="moz-cite-prefix">On 26.08.22 18:44, Norman Barker wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAN_Dn-EV0KYGSBrJ9ap3tE3ihR7+x7v=-b2V0FyHZjV_DMUy4w@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="auto">
        <div>I wrote the original jpipkak driver years ago and it a
          driver I would suggest for deprecation but I am no longer
          involved in j2k development to know how much it is being used.
          <div dir="auto"><br>
          </div>
          <div dir="auto">You will need a jpip server to use the jpip
            client. Wavelets are different to cogs and you will get the
            benefits of progressive display.</div>
          <div dir="auto"><br>
          </div>
          <div dir="auto">Norman</div>
          <br>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">On Fri, Aug 26, 2022, 5:12
              PM Kurt Schwehr <<a href="mailto:schwehr@gmail.com"
                moz-do-not-send="true" class="moz-txt-link-freetext">schwehr@gmail.com</a>>
              wrote:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div dir="auto">It costs, but you could try this:
                <div dir="auto"><br>
                </div>
                <div dir="auto"><a
                    href="https://gdal.org/drivers/raster/jpipkak.html"
                    target="_blank" rel="noreferrer"
                    moz-do-not-send="true" class="moz-txt-link-freetext">https://gdal.org/drivers/raster/jpipkak.html</a><br>
                </div>
                <div dir="auto"><br>
                </div>
                <div dir="auto">I have kakadu, but I have never tried
                  the jpip functionality so I can't say how well it
                  works.</div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Fri, Aug 26, 2022,
                  5:03 AM Martin <<a
                    href="mailto:e11904212@student.tuwien.ac.at"
                    target="_blank" rel="noreferrer"
                    moz-do-not-send="true" class="moz-txt-link-freetext">e11904212@student.tuwien.ac.at</a>>
                  wrote:<br>
                </div>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <div>
                    <p><font face="Arial"> Hi,<br>
                      </font></p>
                    <div>
                      <p
                        style="margin-top:0pt;margin-bottom:10pt;border:none"><font
                          face="Arial"><span style="font-size:11pt">I
                            want to process JP2 data via vsicurl. Which
                            works so far. <br>
                            Unfortunately hundreds of requests are sent,
                            even if only the data of one tile is
                            required. <br>
                            I understand that due to the structure of a
                            JP2 file multiple requests are necessary.
                            But it lo</span><span style="font-size:11pt">oks
                            like GDAL is searching every single tile
                            (resulting in ~120 requests).</span></font></p>
                      <p
                        style="margin-top:0pt;margin-bottom:10pt;border:none"><font
                          face="Arial"><span style="font-size:11pt">Is
                            there a way to reduce the number of
                            requests?<br>
                          </span></font></p>
                      <font face="Arial"> </font>
                      <p
                        style="margin-top:0pt;margin-bottom:10pt;border:none"><font
                          face="Arial"><span style="font-size:11pt">I
                            have already tried the JP2ECW-ERDAS driver,
                            same result.</span></font></p>
                      <p
                        style="margin-top:0pt;margin-bottom:10pt;border:none"><font
                          face="Arial"><span style="font-size:11pt">Do I
                            have to configure GDAL in a certain way?</span></font></p>
                      <font face="Arial"> </font>
                      <p
                        style="margin-top:0pt;margin-bottom:10pt;border:none"><font
                          face="Arial"><span style="font-size:11pt">cmd
                            for request:</span></font></p>
                      <font face="Arial"> </font>
                      <p><font face="Arial">    #!/bin/bash<br>
                        </font> <font face="Arial"><br>
                              export GDAL_DISABLE_READDIR_ON_OPEN="YES"<br>
                              export
                          CPL_VSIL_CURL_ALLOWED_EXTENSIONS="jp2"<br>
                              export CPL_CURL_VERBOSE="YES"<br>
                              export
                          GDAL_HTTP_MERGE_CONSECUTIVE_RANGES="YES"<br>
                        </font> <font face="Arial"><br>
                              gdal_translate --debug ON -srcwin 0 0 256
                          256 /vsicurl/<a
                            href="http://localhost:8083/T33UWP_20220515T100031_TCI_10m_J2Lmin.jp2"
                            rel="noreferrer noreferrer" target="_blank"
                            moz-do-not-send="true"
                            class="moz-txt-link-freetext">http://localhost:8083/T33UWP_20220515T100031_TCI_10m_J2Lmin.jp2</a>
                          ./out_subWin.tif<br>
                        </font> </p>
                      <font face="Arial"> </font>
                      <p
                        style="margin-top:0pt;margin-bottom:10pt;border:none"><font
                          face="Arial"><span style="font-size:11pt">What
                            options do I need to specify when creating
                            the JP2 file to support GDAL?</span></font></p>
                      <font face="Arial"> </font>
                      <p
style="margin-top:0pt;margin-bottom:10pt;border:none;border-left:none;border-top:none;border-right:none;border-bottom:none"><font
                          face="Arial"><span style="font-size:11pt">Currently
                            I use the following options:</span></font></p>
                      <font face="Arial"> </font>
                      <p
style="margin-top:0pt;margin-bottom:10pt;border:none;border-left:none;border-top:none;border-right:none;border-bottom:none"><span
                          style="font-family: "Arial";
                          font-size: 11pt;"><font face="Arial">   
                            #!/bin/bash<br>
                            <br>
                                gdal_translate \<br>
                                    -of JP2OpenJPEG \<br>
                                    -co QUALITY=100 \<br>
                                    -co TLM=YES \<br>
                                    -co PLT=YES \<br>
                                    -co PROGRESSION=LRCP \<br>
                                    -co WRITE_METADATA=YES \<br>
                                   
                            ../test_data/T33UWP_20220515T100031_TCI_10m.tif
                            \<br>
                                   
                            ./T33UWP_20220515T100031_TCI_10m_J2Lmin.jp2</font></span></p>
                      <p
style="margin-top:0pt;margin-bottom:10pt;border:none;border-left:none;border-top:none;border-right:none;border-bottom:none"><span
                          style="font-family: "Arial";
                          font-size: 11pt;"><font face="Arial">Some
                            logs:</font></span></p>
                      <p
style="margin-top:0pt;margin-bottom:10pt;border:none;border-left:none;border-top:none;border-right:none;border-bottom:none"><span
                          style="font-family: "Arial";
                          font-size: 11pt;"><font face="Arial">[gdal
                            degug output](<a
                              href="https://pastebin.com/vTf7tjLJ"
                              rel="noreferrer noreferrer"
                              target="_blank" moz-do-not-send="true"
                              class="moz-txt-link-freetext">https://pastebin.com/vTf7tjLJ</a>)<br>
                            [nginx logs](<a
                              href="https://pastebin.com/8bWW15Tp"
                              rel="noreferrer noreferrer"
                              target="_blank" moz-do-not-send="true"
                              class="moz-txt-link-freetext">https://pastebin.com/8bWW15Tp</a>)<br>
                            [gdalinfo](<a
                              href="https://pastebin.com/HWSmypEQ"
                              rel="noreferrer noreferrer"
                              target="_blank" moz-do-not-send="true"
                              class="moz-txt-link-freetext">https://pastebin.com/HWSmypEQ</a>)<br>
                          </font></span><span style="font-family:
                          "Arial"; font-size: 11pt;"><font
                            face="Arial">[opj_dump](<a
                              href="https://pastebin.com/rdYbHEnY"
                              rel="noreferrer noreferrer"
                              target="_blank" moz-do-not-send="true"
                              class="moz-txt-link-freetext">https://pastebin.com/rdYbHEnY</a>)<br>
                          </font></span><span style="font-family:
                          "Arial"; font-size: 11pt;"><font
                            face="Arial">[kdu_jp2info](<a
                              href="https://pastebin.com/atVUfeVx"
                              rel="noreferrer noreferrer"
                              target="_blank" moz-do-not-send="true"
                              class="moz-txt-link-freetext">https://pastebin.com/atVUfeVx</a>)</font></span><br>
                        <span
                          style="font-family:'Arial';font-size:11pt;color:#000000"></span></p>
                    </div>
                  </div>
                  _______________________________________________<br>
                  gdal-dev mailing list<br>
                  <a href="mailto:gdal-dev@lists.osgeo.org"
                    rel="noreferrer noreferrer" target="_blank"
                    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 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>
              _______________________________________________<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>
    </blockquote>
  </body>
</html>