<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Sean,</p>
    <p>This looks fine, except for the argv[0] value, "lolwut". What is
      that supposed to be ? I assume GDALWarpAppOptionsNew() fails on
      that and returns NULL.</p>
    <p>The obvious demo for using GDALWarp() is the gdalwarp binary
      itself:
      <a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/master/apps/gdalwarp_bin.cpp">https://github.com/OSGeo/gdal/blob/master/apps/gdalwarp_bin.cpp</a></p>
    <p>The COG driver is also a user of it, perhaps more illustrative
      than the above :
      <a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/master/frmts/gtiff/cogdriver.cpp#L552">https://github.com/OSGeo/gdal/blob/master/frmts/gtiff/cogdriver.cpp#L552</a><br>
    </p>
    <p>Even<br>
    </p>
    <div class="moz-cite-prefix">Le 13/04/2022 à 21:53, Sean Gillies a
      écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:CAOodmJpJpV=Axe9eTZX7VR6OX=x1HgWwMfmtd4tsAHmBQh7YHw@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">
          <div>Hi all,</div>
          <div><br>
          </div>
          <div>I'm trying to figure out how to use the GDALWarp function
            from gdalwarp_lib.cpp. It looks like it takes a pointer to a
            GDALWarpAppOptions structure that is parsed from a string
            list, basically gdalwarp's argv, right?</div>
          <div><br>
          </div>
          <div>I'm able to get it to warp data, but the options,
            specifically the resampling option, don't seem to be passed
            into the warper. The output is the same for all resampling
            values.</div>
          <div><br>
          </div>
          <div>Here's my C usage (Cython, actually, but translates to
            C).</div>
          <div><br>
          </div>
          <div>    cdef GDALWarpAppOptions *warp_options = NULL         
                           <br>
          </div>
          <div>    cdef char **argv = NULL                             
                                                                       
                                    </div>
          <div>    try:                                                 
                                                                       
                                             <br>
                    argv = CSLAddString(argv, <const char
            *>"lolwut")<br>
                    resampling_opt_value = Resampling(resampling).name 
            # like "bilinear"<br>
                    argv = CSLAddString(argv, <const char *>"-r")<br>
                    argv = CSLAddString(argv, <const char
            *>resampling_opt_value)<br>
          </div>
          <div>        ...</div>
          <div>        CSLPrint(argv, NULL)<br>
                    warp_options = GDALWarpAppOptionsNew(argv, NULL)<br>
                    output_ds = GDALWarp(<br>
                        NULL,<br>
                        dst_dataset,<br>
                        1, <br>
                        src_datasets,<br>
                        warp_options,<br>
                        NULL<br>
                    )<br>
                finally:</div>
          <div>        ...</div>
          <div><br>
          </div>
          <div>The printed output, my argv, is</div>
          <div><br>
          </div>
          <div>    lolwut<br>
                -r<br>
                bilinear<br>
          </div>
          <div><br>
          </div>
          <div>Does GDALWarpAppOptionsNew expect more values at the head
            of the command line? Is that why it is missing "-r"? Or is
            my string list made up of the wrong kind of strings?
            Documentation examples of building the arguments for
            GDALWarp are scarce. I'd be super grateful for help from
            anyone who has got code this to work.</div>
          <div><br>
          </div>
          <div>Thanks,</div>
          <div class="gmail-adL"><br>
          </div>
        </div>
        -- <br>
        <div dir="ltr" class="gmail_signature"
          data-smartmail="gmail_signature">Sean Gillies</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>