<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Joaquim,</p>
<p><a class="moz-txt-link-freetext" href="https://www.loc.gov/preservation/digital/formats/fdd/fdd000440.shtml">https://www.loc.gov/preservation/digital/formats/fdd/fdd000440.shtml</a>
mentions HDF5, but I don't know if it is HDF5-only or the HDF5
profile of netCDF 4.</p>
<p>From my tests trying to simulate the situation (I don't have a
.mat file handy),</p>
<p>- if it is netCDF 3 file (non-HDF5), the netCDF driver should be
able to open even with the .mat extension</p>
<p>- if it is netCDF 4 file, <br>
</p>
<p> - and the netCDF and HDF5 drivers are present, the HDF5
driver will kick in. The reason is that there's no easy way to
recognize a HDF5 file from a netCDF 4 from their header, so the
netCDF driver has a white list of extensions (which doesn't
include .mat) when it sees the HDF5 driver is there, since it
knows it is a potential fallback<br>
</p>
<p> - and only the netCDF driver is present, it will kick in</p>
<p> - and only the HDF5 driver is present, it will kick in</p>
<p>So basically I don't reproduce your issue.</p>
<p>You should be able to force the NetCDF driver by prefixing
"NETCDF:" to the filename (the -if flag only restricts drivers
which are probed. it doesn't force a driver to accept a file)</p>
<p>Even<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">Le 18/04/2022 à 18:31, Joaquim Manuel
Freire Luís a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:AM6PR04MB39593931D7B47162A9CE6FA0A6F39@AM6PR04MB3959.eurprd04.prod.outlook.com">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi,</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Matlab creates files in
what they call the “mat” format (with a .mat extension) but
which in fact are files in netCDF/HDF
</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">And indeed we can read
them … but only if renamed to .nc</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Why is this failing?</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">$ gdalinfo -if netCDF
windaa.mat</span></p>
<p class="MsoNormal"><span lang="EN-US">ERROR 4: `windaa.mat'
not recognized as a supported file format.</span></p>
<p class="MsoNormal"><span lang="EN-US">gdalinfo failed - unable
to open 'windaa.mat'.</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">But this works</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">$ gdalinfo windaa.nc</span></p>
<p class="MsoNormal"><span lang="EN-US">Driver: netCDF/Network
Common Data Format</span></p>
<p class="MsoNormal"><span lang="EN-US">Files: windaa.nc</span></p>
<p class="MsoNormal"><span lang="EN-US">Size is 512, 512</span></p>
<p class="MsoNormal"><span lang="EN-US">Subdatasets:</span></p>
<p class="MsoNormal"><span lang="EN-US">
SUBDATASET_1_NAME=NETCDF:"windaa.nc":u</span></p>
<p class="MsoNormal"><span lang="EN-US">
SUBDATASET_1_DESC=[15x41x35] u (64-bit floating-point)</span></p>
<p class="MsoNormal"><span lang="EN-US">
SUBDATASET_2_NAME=NETCDF:"windaa.nc":v</span></p>
<p class="MsoNormal"><span lang="EN-US">
SUBDATASET_2_DESC=[15x41x35] v (64-bit floating-point)</span></p>
<p class="MsoNormal"><span lang="EN-US">…</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Joaquim</span></p>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</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>