<div dir="ltr">Super helpful. I was incorrectly thinking of `GDALWarp` as the lower-level entrypoint that the other warper calls used, which is where I got confused. Sounds like `GDALWarp` is basically the entrypoint for the `gdalwarp` executable, hence the string-oriented API. I should go back and study the C++ code again.<div><div><br></div><div>I'll check out the pythonic binding for further inspiration. </div><div><br></div><div>Simeon</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 31, 2024 at 3:52 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"><u></u>

  
    
  
  <div>
    <p>Simeon,<br>
    </p>
    <div>Le 31/01/2024 à 21:38, Fitch, Simeon
      via gdal-dev a écrit :<br>
    </div>
    <blockquote type="cite">
      
      <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">
      <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">
      <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 lang="en"><span>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 cols="72">-- 
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </div>

</blockquote></div>

<br>
<font face="Verdana" color="#808080" size="1">The content of this email is intended for the person or entity to which it is addressed only. This email may contain confidential information. If you are not the person to whom this message is addressed, be aware that any use, reproduction, or distribution of this message is strictly prohibited. If you received this in error, please contact the sender and immediately delete this email and any attachments.</font><br>