I think the mail system refused the mat file in my previous mail. Let’s try with it zipped.
From: gdal-dev <gdal-dev-boun...@lists.osgeo.org> On Behalf Of Joaquim Manuel Freire Luís Sent: Monday, April 18, 2022 7:50 PM To: Even Rouault <even.roua...@spatialys.com>; gdal-dev@lists.osgeo.org Subject: Re: [gdal-dev] -if netCDF fails to read Matlab .mat files Strange, I don’t see an HDF5 driver in my list of drivers but I do include it in the GDAL build. $ gdalinfo --formats | grep HDF HDF4 -raster,multidimensional raster- (ros): Hierarchical Data Format Release 4 HDF4Image -raster- (rw+): HDF4 Dataset Also $ gdalinfo "NETCDF:"U.mat ERROR 4: NETCDF:U.mat: No such file or directory gdalinfo failed - unable to open 'NETCDF:U.mat'. I’m sending attached the U.mat file From: Even Rouault <even.roua...@spatialys.com<mailto:even.roua...@spatialys.com>> Sent: Monday, April 18, 2022 7:07 PM To: Joaquim Manuel Freire Luís <jl...@ualg.pt<mailto:jl...@ualg.pt>>; gdal-dev@lists.osgeo.org<mailto:gdal-dev@lists.osgeo.org> Subject: Re: [gdal-dev] -if netCDF fails to read Matlab .mat files Joaquim, https://www.loc.gov/preservation/digital/formats/fdd/fdd000440.shtml mentions HDF5, but I don't know if it is HDF5-only or the HDF5 profile of netCDF 4. From my tests trying to simulate the situation (I don't have a .mat file handy), - if it is netCDF 3 file (non-HDF5), the netCDF driver should be able to open even with the .mat extension - if it is netCDF 4 file, - 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 - and only the netCDF driver is present, it will kick in - and only the HDF5 driver is present, it will kick in So basically I don't reproduce your issue. 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) Even Le 18/04/2022 à 18:31, Joaquim Manuel Freire Luís a écrit : Hi, Matlab creates files in what they call the “mat” format (with a .mat extension) but which in fact are files in netCDF/HDF And indeed we can read them … but only if renamed to .nc Why is this failing? $ gdalinfo -if netCDF windaa.mat ERROR 4: `windaa.mat' not recognized as a supported file format. gdalinfo failed - unable to open 'windaa.mat'. But this works $ gdalinfo windaa.nc Driver: netCDF/Network Common Data Format Files: windaa.nc Size is 512, 512 Subdatasets: SUBDATASET_1_NAME=NETCDF:"windaa.nc":u SUBDATASET_1_DESC=[15x41x35] u (64-bit floating-point) SUBDATASET_2_NAME=NETCDF:"windaa.nc":v SUBDATASET_2_DESC=[15x41x35] v (64-bit floating-point) … Joaquim _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org<mailto:gdal-dev@lists.osgeo.org> https://lists.osgeo.org/mailman/listinfo/gdal-dev -- http://www.spatialys.com My software is free, but my time generally not.
<<attachment: U.mat.zip>>
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev