<div dir="auto">Hi Micha,<div dir="auto"><br></div><div dir="auto">I answered the question on stackex change. Essentially, you have to provide the CF axis metadata now. This can be addressed in rioxarray using rio.write_coordinate_system.</div><div dir="auto"><br></div><div dir="auto">Hopefully this is helpful,</div><div dir="auto">Alan</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 7, 2022, 7:04 AM Micha Silver <<a href="mailto:tsvibar@gmail.com">tsvibar@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div 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 href="https://gis.stackexchange.com/questions/442323/changes-to-gdal-netcdf-driver-between-3-2-and-3-4" target="_blank" rel="noreferrer">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 cols="72">--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918</pre>
</div>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank" rel="noreferrer">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div>