Sean,
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.
The obvious demo for using GDALWarp() is the gdalwarp binary itself:
https://github.com/OSGeo/gdal/blob/master/apps/gdalwarp_bin.cpp
The COG driver is also a user of it, perhaps more illustrative than the
above :
https://github.com/OSGeo/gdal/blob/master/frmts/gtiff/cogdriver.cpp#L552
Even
Le 13/04/2022 à 21:53, Sean Gillies a écrit :
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
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
--
http://www.spatialys.com
My software is free, but my time generally not.
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev