<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Simeon,<br>
</p>
<div class="moz-cite-prefix">Le 31/01/2024 à 21:38, Fitch, Simeon
via gdal-dev a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:CAAsstvEbfAQUKjNf2NWc7+m4fguzyZvdsaZWVX8GoCGt05Q15w@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">I'm on the `georust/gdal` bindings team, working on
the warp routines, and trying to understand the relationship
between GDALWarpOptions vs GDALWarpAppOptions.
<div><br>
</div>
<div>I'm not seeing any way to create a GDALWarpOptions from a
GDALWarpAppOptions or vice versa. Are functions needing
GDALWarpOptions in a completely different universe from ones
needing GDALWarpAppOptions? <br>
</div>
</div>
</blockquote>
<p>Yes. GDALWarpOptions is for the lower level API from gdalwarper.h</p>
<br>
<blockquote type="cite"
cite="mid:CAAsstvEbfAQUKjNf2NWc7+m4fguzyZvdsaZWVX8GoCGt05Q15w@mail.gmail.com">
<div dir="ltr">
<div>GDALWarpOptions seems clear, with requisite C functions for
manipulating it, whereas GDALWarpAppOptions seems to only
accept key/value pairs via GDALWarpAppOptionsSetWarpOption,
which seems quite limiting.</div>
</div>
</blockquote>
<p>GDALWarpAppOptions is for the higher level gdalwarp C API.
Actually most of the options are to be provided through the
papszArgv parameter of the GDALWarpAppOptionsNew() function. I'm
not sure to remember why the GDALWarpAppOptionsSetWarpOption()
function was added, since it is redundant to passing "-wo",
"{KEY}={VALUE}" as papszArgv values.<br>
</p>
<p>I recognize that key/value pairs or strings are admittedly not
super structured, but they are easily extensible in a way that is
compatible of a stable C API/ABI.<br>
</p>
<br>
<blockquote type="cite"
cite="mid:CAAsstvEbfAQUKjNf2NWc7+m4fguzyZvdsaZWVX8GoCGt05Q15w@mail.gmail.com">
<div dir="ltr">
<div><br>
</div>
<div>I was hoping to provide users a single entry point for
specifying warp options, but wanted some expert advice before
going down a dead end.</div>
</div>
</blockquote>
<p>I guess both API could be mapped. GDALWarp() is probably easier
for most users as it combines different low level methods, like
calling GDALSuggestedWarpOutput2() to find the target extent and
resolution, creating the new dataset, etc. If you look at
gdalwarp_lib.cpp, you'll find there are lots of heuristics there.</p>
<p>Nothing prevents you to provide a more <span class="ILfuVd"
lang="en"><span class="hgKElc">Rustacean</span></span> API than
the string-based one of GDALWarp(). The Python bindings for
examples provide a way of providing the options as keyword
options:<br>
</p>
<p><br>
</p>
<p>WarpOptions(options=None, format=None, srcBands=None,
dstBands=None, outputBounds=None, outputBoundsSRS=None, xRes=None,
yRes=None, targetAlignedPixels=False, width=0, height=0,
srcSRS=None, dstSRS=None, coordinateOperation=None, srcAlpha=None,
dstAlpha=False, warpOptions=None, errorThreshold=None,
warpMemoryLimit=None, creationOptions=None, outputType=0,
workingType=0, resampleAlg=None, srcNodata=None, dstNodata=None,
multithread=False, tps=False, rpc=False, geoloc=False,
polynomialOrder=None, transformerOptions=None, cutlineDSName=None,
cutlineLayer=None, cutlineWhere=None, cutlineSQL=None,
cutlineBlend=None, cropToCutline=False, copyMetadata=True,
metadataConflictValue=None, setColorInterpretation=False,
overviewLevel='AUTO', callback=None, callback_data=None)<br>
Create a WarpOptions() object that can be passed to
gdal.Warp()<br>
<br>
Parameters<br>
----------<br>
options:<br>
can be be an array of strings, a string or let empty and
filled from other keywords.<br>
format:<br>
output format ("GTiff", etc...)<br>
srcBands:<br>
list of source band numbers (between 1 and the number of
input bands)<br>
dstBands:<br>
list of output band numbers<br>
outputBounds:<br>
output bounds as (minX, minY, maxX, maxY) in target SRS<br>
outputBoundsSRS:<br>
SRS in which output bounds are expressed, in the case they
are not expressed in dstSRS<br>
xRes:<br>
output resolution in target SRS<br>
yRes:<br>
output resolution in target SRS<br>
targetAlignedPixels:<br>
whether to force output bounds to be multiple of output
resolution<br>
width:<br>
width of the output raster in pixel<br>
height:<br>
height of the output raster in pixel<br>
srcSRS:<br>
source SRS<br>
dstSRS:<br>
output SRS<br>
coordinateOperation:<br>
coordinate operation as a PROJ string or WKT string<br>
srcAlpha:<br>
whether to force the last band of the input dataset to be
considered as an alpha band.<br>
If set to False, source alpha warping will be disabled.<br>
dstAlpha:<br>
whether to force the creation of an output alpha band<br>
outputType:<br>
output type (gdalconst.GDT_Byte, etc...)<br>
workingType:<br>
working type (gdalconst.GDT_Byte, etc...)<br>
warpOptions:<br>
list or dict of warping options<br>
errorThreshold:<br>
error threshold for approximation transformer (in pixels)<br>
warpMemoryLimit:<br>
size of working buffer in MB<br>
resampleAlg:<br>
resampling mode<br>
creationOptions:<br>
list or dict of creation options<br>
srcNodata:<br>
source nodata value(s)<br>
dstNodata:<br>
output nodata value(s)<br>
multithread:<br>
whether to multithread computation and I/O operations<br>
tps:<br>
whether to use Thin Plate Spline GCP transformer<br>
rpc:<br>
whether to use RPC transformer<br>
geoloc:<br>
whether to use GeoLocation array transformer<br>
polynomialOrder:<br>
order of polynomial GCP interpolation<br>
transformerOptions:<br>
list or dict of transformer options<br>
cutlineDSName:<br>
cutline dataset name<br>
cutlineLayer:<br>
cutline layer name<br>
cutlineWhere:<br>
cutline WHERE clause<br>
cutlineSQL:<br>
cutline SQL statement<br>
cutlineBlend:<br>
cutline blend distance in pixels<br>
cropToCutline:<br>
whether to use cutline extent for output bounds<br>
copyMetadata:<br>
whether to copy source metadata<br>
metadataConflictValue:<br>
metadata data conflict value<br>
setColorInterpretation:<br>
whether to force color interpretation of input bands to
output bands<br>
overviewLevel:<br>
To specify which overview level of source files must be
used<br>
callback:<br>
callback method<br>
callback_data:<br>
user data for callback<br>
<br>
<br>
</p>
<p>Even<br>
</p>
<span style="white-space: pre-wrap">
</span>
<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>