[gdal-dev] GDALWarpAppOptionsNew and GDALWarp usage?

Sean Gillies sean.gillies at gmail.com
Wed Apr 13 12:53:01 PDT 2022


Hi all,

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?

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.

Here's my C usage (Cython, actually, but translates to C).

    cdef GDALWarpAppOptions *warp_options = NULL
    cdef char **argv = NULL

    try:

        argv = CSLAddString(argv, <const char *>"lolwut")
        resampling_opt_value = Resampling(resampling).name  # like
"bilinear"
        argv = CSLAddString(argv, <const char *>"-r")
        argv = CSLAddString(argv, <const char *>resampling_opt_value)
        ...
        CSLPrint(argv, NULL)
        warp_options = GDALWarpAppOptionsNew(argv, NULL)
        output_ds = GDALWarp(
            NULL,
            dst_dataset,
            1,
            src_datasets,
            warp_options,
            NULL
        )
    finally:
        ...

The printed output, my argv, is

    lolwut
    -r
    bilinear

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.

Thanks,

-- 
Sean Gillies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220413/93130be5/attachment.html>


More information about the gdal-dev mailing list