<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body>
    <p>Ah, is it using the Memory driver ? As I saw a /vsimem/ filename
      and mention of gmt, I assumed you create a GMT file in /vsimem/,
      for which my example would have worked. But if you use the Memory
      driver, there's no way you can't use it as a cutline, since a
      dataset of the Memory driver can't be re-opened. You can just use
      the handle returned by the create method.<br>
    </p>
    <div class="moz-cite-prefix">Le 31/03/2021 à 20:03, Joaquim Manuel
      Freire Luís a écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:AM6PR04MB395964D8E828737A96A8A077A67C9@AM6PR04MB3959.eurprd04.prod.outlook.com">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <div class="WordSection1">
        <p class="MsoNormal"><span lang="EN-US">This one is resisting. I
            can’t spot any difference from your python example but it
            still fails.</span></p>
        <p class="MsoNormal"><span lang="EN-US"> </span></p>
        <p class="MsoNormal"><span lang="EN-US">What you mean by “</span><span
            class="pl-s"><span lang="EN-US">Make sure that the cutline
              dataset is properly closed”.</span></span></p>
        <p class="MsoNormal"><span class="pl-s"><span lang="EN-US">If I
              call GDALClose on it, then it disappears.</span></span></p>
        <p class="MsoNormal"><span class="pl-s"><span lang="EN-US">(note,
              I also tried by creating a
            </span></span><span lang="EN-US">"/vsimem/cut.shp" Memory
            cutline but the result was the same)</span></p>
        <p class="MsoNormal"><span class="pl-s"><span lang="EN-US"> </span></span></p>
        <p class="MsoNormal"><span class="pl-s"><span lang="EN-US"> </span></span></p>
        <p class="MsoNormal"><span lang="EN-US">GDALGetDescription(ds.ptr)</span></p>
        <p class="MsoNormal"><span lang="EN-US">"/vsimem/##280"</span></p>
        <p class="MsoNormal"><span lang="EN-US"> </span></p>
        <p class="MsoNormal"><span lang="EN-US">GDALClose(ds.ptr)</span></p>
        <p class="MsoNormal"><span lang="EN-US"> </span></p>
        <p class="MsoNormal"><span lang="EN-US">GDALGetDescription(ds.ptr)</span></p>
        <p class="MsoNormal"><span lang="EN-US">“”</span></p>
        <p class="MsoNormal"><span lang="EN-US"> </span></p>
        <div>
          <div>
            <p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span
                lang="EN-US"> Even Rouault
                <a class="moz-txt-link-rfc2396E" href="mailto:even.rouault@spatialys.com"><even.rouault@spatialys.com></a>
                <br>
                <b>Sent:</b> Wednesday, March 31, 2021 2:43 PM<br>
                <b>To:</b> Joaquim Manuel Freire Luís
                <a class="moz-txt-link-rfc2396E" href="mailto:jluis@ualg.pt"><jluis@ualg.pt></a>; <a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
                <b>Subject:</b> Re: [gdal-dev] using an in-memory file
                as -cutline argument in gdalwarp</span></p>
          </div>
        </div>
        <p class="MsoNormal"> </p>
        <p>Joaquim,</p>
        <p>yes, you should be able to use a /vsimem/ file as a cutline
          dataset. Here's an example in Python with a shapefile in
          /vsimem/:</p>
        <p><a
href="https://github.com/OSGeo/gdal/blob/fec15b146f8a750c23c5e765cac12ed5fc9c2b85/autotest/utilities/test_gdalwarp_lib.py#L1103"
            moz-do-not-send="true">https://github.com/OSGeo/gdal/blob/fec15b146f8a750c23c5e765cac12ed5fc9c2b85/autotest/utilities/test_gdalwarp_lib.py#L1103</a></p>
        <p>The <span class="pl-s1">cutlineDSName</span><span
            class="pl-c1">=</span><span class="pl-s"> is just python
            syntaxic sugar to format the arguments. There's no reason it
            shouldn't work in Julia too</span></p>
        <p><span class="pl-s">Make sure that the cutline dataset is
            properly closed, before using it with gdalwarp</span></p>
        <p><span class="pl-s">Even</span></p>
        <p class="MsoNormal">Le 31/03/2021 à 15:34, Joaquim Manuel
          Freire Luís a écrit :<br>
          <br>
        </p>
        <blockquote>
          <div>
            <p class="MsoNormal"><span lang="EN-US">I have low hopes on
                this one but have to confirm.</span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US">I have this “ds”
                dataset with one polygon geometry, which is correctly
                saved on disk with</span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US">ogr2ogr(ds,
                save="lixo.gmt")</span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US">and later correctly
                “cutlines” with</span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US">gdalwarp("IMG_9106.jpg",
                ["-cutline", "lixo.gmt", "-to",
                "SRC_METHOD=NO_GEOTRANSFORM"]);</span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US">but I wanted to
                avoid the step of saving to disk and instead using the
                inMemory file. If I ask its name, I see</span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US">GDALGetDescription(ds.ptr)</span></p>
            <p class="MsoNormal"><span lang="EN-US">"/vsimem/##258"</span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US">But this fails</span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US">gdalwarp("IMG_9106.jpg",
                ["-cutline", GDALGetDescription(ds.ptr), "-to",
                "SRC_METHOD=NO_GEOTRANSFORM"])</span></p>
            <p class="MsoNormal"><span lang="EN-US">NULL Dataset</span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US">Can this be made to
                work (would it work with the python bindings?) and I’m
                just doing it wrong or it just can’t?</span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US">Thanks</span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US">Joaquim</span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
          </div>
          <p class="MsoNormal"><br>
            <br>
          </p>
          <pre>_______________________________________________</pre>
          <pre>gdal-dev mailing list</pre>
          <pre><a href="mailto:gdal-dev@lists.osgeo.org" moz-do-not-send="true">gdal-dev@lists.osgeo.org</a></pre>
          <pre><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></pre>
        </blockquote>
        <pre>-- </pre>
        <pre><a href="http://www.spatialys.com" moz-do-not-send="true">http://www.spatialys.com</a></pre>
        <pre>My software is free, but my time generally not.</pre>
      </div>
    </blockquote>
    <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>