<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">Le 04/07/2022 à 11:00, Bart via PROJ a
      écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:003e01d88f84$819a7cb0$84cf7610$@ziggo.nl">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}div.WordSection1
        {page:WordSection1;}ol
        {margin-bottom:0cm;}ul
        {margin-bottom:0cm;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span lang="EN-US">Greetings all,<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">Working with QGIS, I am
            in need of developing a ‘custom CRS’ with its own origin and
            orientation. <o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">Basically I need a CRS
            that is DERIVED from a PROJCRS, resulting in a <b>DERIVEDPROJCRS</b>.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">I have done some work to
            that extent, that can be seen at the following spreadsheet
            on GitHub:<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><a
href="https://github.com/Duijndam-Dev/TopoLib/blob/master/TopoLib/Samples/DerivedProjectedCrsTests.xlsb"
              moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/Duijndam-Dev/TopoLib/blob/master/TopoLib/Samples/DerivedProjectedCrsTests.xlsb</a><o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">Right now, I do this by
            hacking a WKT2 string, based on various examples found on
            the internet.<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:36.0pt"><a
href="https://gis.stackexchange.com/questions/353022/defining-a-coordinate-system-in-wkt-or-proj-format-that-has-an-affine-transforma"
            moz-do-not-send="true" class="moz-txt-link-freetext">https://gis.stackexchange.com/questions/353022/defining-a-coordinate-system-in-wkt-or-proj-format-that-has-an-affine-transforma</a>
          <span lang="EN-US"><o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:36.0pt"><a
href="https://gis.stackexchange.com/questions/350228/define-custom-projection-in-qgis-from-some-control-points"
            moz-do-not-send="true" class="moz-txt-link-freetext">https://gis.stackexchange.com/questions/350228/define-custom-projection-in-qgis-from-some-control-points</a>
          <span lang="EN-US"><o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:36.0pt"><a
href="https://gis.stackexchange.com/questions/408406/qgis-custom-projection-in-wkt-not-saving-prj-file"
            moz-do-not-send="true" class="moz-txt-link-freetext">https://gis.stackexchange.com/questions/408406/qgis-custom-projection-in-wkt-not-saving-prj-file</a>
          <span lang="EN-US"><o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:36.0pt"><a
href="https://gis.stackexchange.com/questions/366578/custom-crs-for-historic-site-grid"
            moz-do-not-send="true" class="moz-txt-link-freetext">https://gis.stackexchange.com/questions/366578/custom-crs-for-historic-site-grid</a>
          <span lang="EN-US"><o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:36.0pt"><a
href="https://gis.stackexchange.com/questions/408683/custom-derived-crs-by-affine-transformation-from-epsg32633-setting-as-layer-cr"
            moz-do-not-send="true" class="moz-txt-link-freetext">https://gis.stackexchange.com/questions/408683/custom-derived-crs-by-affine-transformation-from-epsg32633-setting-as-layer-cr</a>
          <span lang="EN-US"><o:p></o:p></span></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span lang="EN-US">Doing the required
            affine transform is relatively straightforward. What is more
            of a concern is creating a WKT2 string to setup the
            DERIVEDPROJCRS.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">In particular, I would
            like to preserve the USAGE definition and BBOX field. Any
            closing ID field needs to be removed, as it is no longer
            valid.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">But the process of
            editing a WKT2 string is rather error prone. It is not
            something you’d like a ‘novice’ having to do.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">Now, the fact is that
            proj supports affine transforms since v6.0.0. See: <a
href="https://proj.org/operations/transformations/affine.html?highlight=affine+transformation#"
              moz-do-not-send="true" class="moz-txt-link-freetext">https://proj.org/operations/transformations/affine.html?highlight=affine+transformation#</a><o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">Finally, to come to my
            question: would it be possible to define the following
            workflow in C++ code:<o:p></o:p></span></p>
        <ol style="margin-top:0cm" type="1" start="1">
          <li class="MsoListParagraph"
            style="margin-left:0cm;mso-list:l0 level1 lfo1"><span
              lang="EN-US">Create a projected CRS object (from EPSG
              code, or a WKT string)<o:p></o:p></span></li>
          <li class="MsoListParagraph"
            style="margin-left:0cm;mso-list:l0 level1 lfo1"><span
              lang="EN-US">Apply an affine transformation on this CRS<o:p></o:p></span></li>
          <li class="MsoListParagraph"
            style="margin-left:0cm;mso-list:l0 level1 lfo1"><span
              lang="EN-US">Export the modified CRS as a WKT string<o:p></o:p></span></li>
        </ol>
        <p class="MsoNormal"><span lang="EN-US">This automation would
            avoid any manual editing of the WKT2 string.</span></p>
      </div>
    </blockquote>
    <p>There's definitely everything needed in PROJ C++ API to do that.</p>
    <p>The main entry point would be the DerivedProjectedCRS::create()
      method:
      <a class="moz-txt-link-freetext" href="https://github.com/OSGeo/PROJ/blob/master/include/proj/crs.hpp#L1266">https://github.com/OSGeo/PROJ/blob/master/include/proj/crs.hpp#L1266</a></p>
    <p>There's an example of its usage in
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/PROJ/blob/a390c57ab5998154535d7ffbc7de04aad2a73910/test/unit/test_crs.cpp#L5493">https://github.com/OSGeo/PROJ/blob/a390c57ab5998154535d7ffbc7de04aad2a73910/test/unit/test_crs.cpp#L5493</a></p>
    <p>In this example, the creation of the conversion is rather dummy.
      A more interesting example is at
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/PROJ/blob/a390c57ab5998154535d7ffbc7de04aad2a73910/test/unit/test_crs.cpp#L5164">https://github.com/OSGeo/PROJ/blob/a390c57ab5998154535d7ffbc7de04aad2a73910/test/unit/test_crs.cpp#L5164</a></p>
    <p>Creation of the base CRS from a EPSG code:
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/PROJ/blob/a390c57ab5998154535d7ffbc7de04aad2a73910/test/unit/test_crs.cpp#L1225">https://github.com/OSGeo/PROJ/blob/a390c57ab5998154535d7ffbc7de04aad2a73910/test/unit/test_crs.cpp#L1225</a></p>
    <p>Export of a CRS as WKT:
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/PROJ/blob/a390c57ab5998154535d7ffbc7de04aad2a73910/test/unit/test_crs.cpp#L2047">https://github.com/OSGeo/PROJ/blob/a390c57ab5998154535d7ffbc7de04aad2a73910/test/unit/test_crs.cpp#L2047</a><br>
    </p>
    <p>Even<br>
    </p>
    <blockquote type="cite"
      cite="mid:003e01d88f84$819a7cb0$84cf7610$@ziggo.nl">
      <div class="WordSection1">
        <p class="MsoNormal"><span lang="EN-US"><o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">Maybe - if this isn’t
            the best approach - are any other ways conceivable to
            achieve my goal ?<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-US">Much appreciate your
            advice.<o:p></o:p></span></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span
            style="font-size:12.0pt;mso-fareast-language:#0C00"
            lang="NL"><a href="mailto:Bart.Duijndam@ziggo.nl"
              moz-do-not-send="true"><span lang="EN-US">Bart Duijndam</span></a></span><span
            style="font-size:12.0pt;mso-fareast-language:#0C00"
            lang="EN-US"><o:p></o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:#0C00"
            lang="EN-US">Geoscience consultant<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:#0C00"
            lang="NL"><a href="http://www.duijndam.dev/"
              moz-do-not-send="true">www.duijndam.dev</a> <o:p></o:p></span></p>
        <p class="MsoNormal"><o:p> </o:p></p>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
PROJ mailing list
<a class="moz-txt-link-abbreviated" href="mailto:PROJ@lists.osgeo.org">PROJ@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/proj">https://lists.osgeo.org/mailman/listinfo/proj</a>
</pre>
    </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>