<div dir="ltr"><div dir="ltr"><div>Thanks, Even!</div><div><br></div><div>When I checked the return of GDALWarpAppOptionsNew() and the error stack, I found that the problem was that I'd been adding an unexpected "-wt Unknown". After screening that out, I'm getting the resampling I expect.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 13, 2022 at 2:10 PM Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<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 href="https://github.com/OSGeo/gdal/blob/master/apps/gdalwarp_bin.cpp" target="_blank">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 href="https://github.com/OSGeo/gdal/blob/master/frmts/gtiff/cogdriver.cpp#L552" target="_blank">https://github.com/OSGeo/gdal/blob/master/frmts/gtiff/cogdriver.cpp#L552</a><br>
</p>
<p>Even<br>
</p>
<div>Le 13/04/2022 à 21:53, Sean Gillies a
écrit :<br>
</div>
<blockquote type="cite">
<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></div></blockquote></div>
</blockquote></div><br>-- <br><div dir="ltr" class="gmail_signature">Sean Gillies</div></div>