<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>André,</p>
    <p>hum ok. it might perhaps be possible that WKT2 could come when
      extract the vertical part but I still can't reproduce that trying:</p>
    <p>$ gdal_translate autotest/gcore/data/byte.tif byte.bag -a_srs
      'COMPOUNDCRS["foo",PROJCRS["NAD27 / UTM zone
      11N",BASEGEOGCRS["NAD27",DATUM["North American Datum
      1927",ELLIPSOID["Clarke
1866",6378206.4,294.978698213898,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4267]],CONVERSION["UTM
      zone 11N",METHOD["Transverse
      Mercator",ID["EPSG",9807]],PARAMETER["Latitude of natural
origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude
      of natural
origin",-117,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Scale
      factor at natural
      origin",0.9996,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False
easting",500000,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False
northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1]],USAGE[SCOPE["Engineering
      survey, topographic mapping."],AREA["North America - between 120°W
      and 114°W - onshore. Canada - Alberta; British Columbia; Northwest
      Territories; Nunavut. Mexico. United States (USA) - California;
      Idaho; Nevada; Oregon;
Washington."],BBOX[26.93,-120,78.13,-114]],ID["EPSG",26711]],VERTCRS["ellipse",VDATUM["NAD83(2011)
      / UTM zone 10N + ellipse"],CS[vertical,1],AXIS["ellipsoid height
      (h)",up,LENGTHUNIT["metre",1]]]]'<br>
    </p>
    <p>$ gdalinfo byte.bag -mdd xml:BAG | grep VERT_CS<br>
                 
      <gco:CharacterString>VERT_CS["ellipse",VERT_DATUM["NAD83(2011)
      / UTM zone 10N + ellipse",2005],UNIT["metre",1],AXIS["Ellipsoid
      height",UP]]</gco:CharacterString><br>
    </p>
    <p>(the ,2005 here isn't really appropriate. it should rather be
      ,2002,  but such formulations of CompoundCRS with a VerticalCRS
      that expressed an ellipsoidal height are not ISO-19111 compliant)<br>
    </p>
    <p>Anyway if you can find a way to reproduce the issue with a CRS
      provided through the GetProjection()/SetProjection() API of GDAL,
      a fix would be welcome. If it is the user who provides WKT2 with a
      manual VAR_VERT_WKT option, then I'd say it is their
      responsibility to provide the right value.<br>
    </p>
    <p>Even<br>
    </p>
    <div class="moz-cite-prefix">Le 22/04/2022 à 18:35, Vautour, André
      (INT) a écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:YT3PR01MB493069B9A790FDCD3529330C97F79@YT3PR01MB4930.CANPRD01.PROD.OUTLOOK.COM">
      <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:"Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
        {font-family:"\@Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        font-size:10.0pt;
        font-family:"Courier New";}span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}div.WordSection1
        {page:WordSection1;}</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">Sorry Even,<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">I should have done more research on my end
          up front before sending this. A client told us his WKT 2.0 BAG
          was created with GDAL. Looking at it some more, it was the
          vertical CRS that was WKT 2.0.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Their vertical CRS looked as follows:<o:p></o:p></p>
        <p class="MsoNormal"><gco:CharacterString>VERTCRS["ellipse",VDATUM["NAD83(2011)
          / UTM zone 10N + ellipse"],CS[vertical,1],AXIS["ellipsoid
          height
          (h)",up,LENGTHUNIT["metre",1]]]</gco:CharacterString><o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Cheers,<o:p></o:p></p>
        <p class="MsoNormal">André<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div>
          <div style="border:none;border-top:solid #E1E1E1
            1.0pt;padding:3.0pt 0cm 0cm 0cm">
            <p class="MsoNormal"><b>From:</b> Even Rouault
              <a class="moz-txt-link-rfc2396E" href="mailto:even.rouault@spatialys.com"><even.rouault@spatialys.com></a> <br>
              <b>Sent:</b> April 22, 2022 13:22<br>
              <b>To:</b> Vautour, André (INT)
              <a class="moz-txt-link-rfc2396E" href="mailto:Andre.Vautour@Teledyne.com"><Andre.Vautour@Teledyne.com></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] BAG CRS<o:p></o:p></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div align="center">
          <table class="MsoNormalTable"
            style="width:112.5pt;border:outset #898989 1.0pt"
            width="150" cellspacing="0" cellpadding="0" border="1">
            <tbody>
              <tr>
                <td style="border:inset #898989
                  1.0pt;background:#FDFFB2;padding:3.0pt 3.0pt 3.0pt
                  3.0pt">
                  <p class="MsoNormal" style="text-align:center"
                    align="center"><span style="font-size:8.0pt">External
                      Email<o:p></o:p></span></p>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
        <p>André,<o:p></o:p></p>
        <p>I don't confirm this trying:<o:p></o:p></p>
        <p>$ gdal_translate autotest/gcore/data/byte.tif byte.bag<o:p></o:p></p>
        <p>$ gdalinfo byte.bag -mdd xml:BAG | grep PROJCS<br>
                      <gco:CharacterString>PROJCS["NAD27 / UTM
          zone
          11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke
1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]]</gco:CharacterString><o:p></o:p></p>
        <p>This is WKT1<o:p></o:p></p>
        <p>I'm wondering if the confusion might come from looking at the
          CRS reported by gdalinfo, which will always be WKT2 in recent
          GDAL versions whatever the encoding in the source dataset
          itself ?<o:p></o:p></p>
        <p>Or perhaps you try to write a Geographic 3D CRS ? in which
          case WKT2 will be used since there's no WKT1 representation
          for this<o:p></o:p></p>
        <p>$ gdalwarp -overwrite autotest/gcore/data/byte.tif byte.bag
          -t_srs EPSG:4979 -ot float32<o:p></o:p></p>
        <p>$ gdalinfo byte.bag -mdd xml:BAG | grep GEOGCRS<br>
                      <gco:CharacterString>GEOGCRS["WGS
          84",ENSEMBLE["World Geodetic System 1984
          ensemble",MEMBER["World Geodetic System 1984
          (Transit)"],MEMBER["World Geodetic System 1984
          (G730)"],MEMBER["World Geodetic System 1984
          (G873)"],MEMBER["World Geodetic System 1984
          (G1150)"],MEMBER["World Geodetic System 1984
          (G1674)"],MEMBER["World Geodetic System 1984
          (G1762)"],MEMBER["World Geodetic System 1984
          (G2139)"],ELLIPSOID["WGS
84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,3],AXIS["geodetic
          latitude
(Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic
          longitude
(Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],AXIS["ellipsoidal
          height (h)",up,ORDER[3],LENGTHUNIT["metre",1]], [... snip
          ....] ,ID["EPSG",4979]]</gco:CharacterString><o:p></o:p></p>
        <p>(I see that gdalinfo also issues a "ERROR 1: PROJ:
          proj_create_compound_crs: components of the compound CRS do
          not belong to one of the allowed combinations of
          <a
            href="http://docs.opengeospatial.org/as/18-005r4/18-005r4.html#34"
            moz-do-not-send="true" class="moz-txt-link-freetext">http://docs.opengeospatial.org/as/18-005r4/18-005r4.html#34</a>"
          when reading this, which I suspect comes from the fact that it
          tries to create a CompoundCRS from this 3D GeogCRS and the
          "VERT_CS["unknown", VERT_DATUM["unknown", 2000]]", so writing
          3D GeogCRS isn't really appropriate for BAG)<o:p></o:p></p>
        <p><span lang="FR-CA">Even<o:p></o:p></span></p>
        <div>
          <p class="MsoNormal"><span lang="FR-CA">Le 22/04/2022 à 18:01,
              Vautour, André (INT) a écrit :<o:p></o:p></span></p>
        </div>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <p class="MsoNormal"><span lang="EN-CA">Hi all,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-CA"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-CA">It has just come to my
              attention that the BAG driver in GDAL is writing the CRS
              with a WKT codeSpace and a WKT 2.0 string as the code.
              While I am fairly sure we started that incorrect practice
              here at CARIS with a WKT 1.0 string, this is the first
              time I’ve seen a WKT 2.0 string written in there, and I am
              therefore concerned about interoperability.</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-CA"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-CA">I think we can all
              agree that what makes the most sense is to write an EPSG
              codebase with the EPSG code if we have it, and I think
              falling back to a WKT 1.0 string if it is not EPSG is a
              reasonable fallback if it is not EPSG, given how it has
              been used in the past, but I am worried that older
              software won’t recognize the WKT 2.0 string.</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-CA"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-CA">Would you be willing
              to take a pull request that does that? Worst-case, would
              you be fine with changing that WKT 2.0 string to a WKT 1.0
              string?</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-CA"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-CA">Regards,</span><o:p></o:p></p>
          <p class="MsoNormal"><span lang="EN-CA">Andr</span>é<o:p></o:p></p>
          <p class="MsoNormal"><br>
            <br>
            <o:p></o:p></p>
          <pre>_______________________________________________<o:p></o:p></pre>
          <pre>gdal-dev mailing list<o:p></o:p></pre>
          <pre><a href="mailto:gdal-dev@lists.osgeo.org" moz-do-not-send="true" class="moz-txt-link-freetext">gdal-dev@lists.osgeo.org</a><o:p></o:p></pre>
          <pre><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" moz-do-not-send="true" class="moz-txt-link-freetext">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></pre>
        </blockquote>
        <pre>-- <o:p></o:p></pre>
        <pre><a href="http://www.spatialys.com" moz-do-not-send="true" class="moz-txt-link-freetext">http://www.spatialys.com</a><o:p></o:p></pre>
        <pre>My software is free, but my time generally not.<o:p></o:p></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>