<html style="direction: ltr;">
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <style id="bidiui-paragraph-margins" type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
  </head>
  <body bidimailui-charset-is-forced="true" style="direction: ltr;">
    <p><font size="4"><font face="Helvetica, Arial, sans-serif">Hello:</font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif">I'm
          using xarray and rioxarray in python to create a DataSet then
          export to Netcdf. After saving, when I check the exported
          files with gdalinfo using GDAL 3.2, I see the correct extent.
          However, when using GDAL >=3.4 (i.e in a conda env) it
          seems that the extents are lost, and the NetCDF dimensions
          appear instead. This causes the resulting NetCDF to appear at
          coords (0,0) - the wrong place - in QGIS (on a system with the
          newer GDAL).<br>
        </font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif"><br>
        </font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif">Here is
          the output with my system installed GDAL:</font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif"><br>
        </font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif"><span
            style="font-family:monospace"><span
              style="font-weight:bold;color:#54ff54;background-color:#ffffff;">micha@RMS</span><span
              style="color:#000000;background-color:#ffffff;">:</span><span
style="font-weight:bold;color:#5454ff;background-color:#ffffff;">Kinneret</span><span
              style="color:#000000;background-color:#ffffff;">$ gdalinfo
              --version </span><br>
            GDAL 3.2.2, released 2021/03/05 <br>
            <span
              style="font-weight:bold;color:#54ff54;background-color:#ffffff;">micha@RMS</span><span
              style="color:#000000;background-color:#ffffff;">:</span><span
style="font-weight:bold;color:#5454ff;background-color:#ffffff;">Kinneret</span><span
              style="color:#000000;background-color:#ffffff;">$ gdalinfo
               NETCDF:"Kinneret_velocity.nc":v | grep -A 4 Corner
                                                </span><br>
            Warning 1: dimension #2 (x) is not a Longitude/X dimension.
            <br>
            Warning 1: dimension #1 (y) is not a Latitude/Y dimension. <br>
            Warning 1: dimension #0 (z) is not a Time or Vertical
            dimension. <br>
            Corner Coordinates: <br>
            Upper Left  (  735758.000, 3644806.000) ( 35d31'15.70"E,
            32d54'57.98"N) <br>
            Lower Left  (  735758.000, 3621606.000) ( 35d30'54.46"E,
            32d42'25.30"N) <br>
            Upper Right (  754558.000, 3644806.000) ( 35d43'18.74"E,
            32d54'42.80"N) <br>
          </span></font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif"><span
            style="font-family:monospace">Lower Right (  754558.000,
            3621606.000) ( 35d42'55.82"E, 32d42'10.25"N) </span></font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif"><span
            style="font-family:monospace"><span
              style="font-weight:bold;color:#54ff54;background-color:#ffffff;"><br>
            </span></span></font></font></p>
    <p>However, in my conda environment, with a newer GDAL:<font
        size="4"><font face="Helvetica, Arial, sans-serif"><span
            style="font-family:monospace"><span
              style="font-weight:bold;color:#54ff54;background-color:#ffffff;"><br>
            </span></span></font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif"><span
            style="font-family:monospace"><span
              style="font-weight:bold;color:#54ff54;background-color:#ffffff;"><br>
            </span></span></font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif"><span
            style="font-family:monospace"><span
              style="font-weight:bold;color:#54ff54;background-color:#ffffff;">micha@RMS</span><span
              style="color:#000000;background-color:#ffffff;">:</span><span
style="font-weight:bold;color:#5454ff;background-color:#ffffff;">Kinneret</span><span
              style="color:#000000;background-color:#ffffff;">$ conda
              activate geo </span><br>
            (geo) <span
              style="font-weight:bold;color:#54ff54;background-color:#ffffff;">micha@RMS</span><span
              style="color:#000000;background-color:#ffffff;">:</span><span
style="font-weight:bold;color:#5454ff;background-color:#ffffff;">Kinneret</span><span
              style="color:#000000;background-color:#ffffff;">$ gdalinfo
              --version </span><br>
            GDAL 3.5.2, released 2022/09/02 <br>
            (geo) <span
              style="font-weight:bold;color:#54ff54;background-color:#ffffff;">micha@RMS</span><span
              style="color:#000000;background-color:#ffffff;">:</span><span
style="font-weight:bold;color:#5454ff;background-color:#ffffff;">Kinneret</span><span
              style="color:#000000;background-color:#ffffff;">$ gdalinfo
               NETCDF:"Kinneret_velocity.nc":v | grep -A 4 Corner </span><br>
            Warning 1: dimension #2 (x) is not a Longitude/X dimension.
            <br>
            Warning 1: dimension #1 (y) is not a Latitude/Y dimension. <br>
            Warning 1: dimension #0 (z) is not a Time or Vertical
            dimension. <br>
            Corner Coordinates: <br>
            Upper Left  (    0.0,    0.0) <br>
            Lower Left  (    0.0,   58.0) <br>
            Upper Right (   47.0,    0.0) <br>
            Lower Right (   47.0,   58.0)<br>
          </span><br>
        </font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif">What do
          I need to add to the xarray Dataset so that the newer GDAL
          gets the correct extent?</font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif">In both
          cases all the "grid_mapping" metadata entries point to
          "spatial_ref", and the full spatial_ref details are available
          in the NetCDF file.</font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif"><br>
        </font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif">(Note:
          double posted to GIS.stackexchange at
<a class="moz-txt-link-freetext" href="https://gis.stackexchange.com/questions/442323/changes-to-gdal-netcdf-driver-between-3-2-and-3-4">https://gis.stackexchange.com/questions/442323/changes-to-gdal-netcdf-driver-between-3-2-and-3-4</a>)<br>
        </font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif"><br>
        </font></font></p>
    <p><font size="4"><font face="Helvetica, Arial, sans-serif">Thanks</font></font></p>
    <p></p>
    <pre class="moz-signature" cols="72">-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918</pre>
  </body>
</html>