[Ubuntu] problem with netcdf-4 files with gdal build

Etienne Tourigny etourigny.dev at gmail.com
Wed Nov 14 04:44:43 PST 2012


Hi,

The ubuntugis-unstable builds of gdal have a problem with netcdf-4
files (which use hdf5 storage).

The consequence is that netcdf-4 files are not supported in apps that
use gdal (like qgis), because the hdf5 driver does not read dimension
information of netcdf-4 files.

Long story short - proper detection of netcdf-4 support in gdal netcdf
driver requires nc-config which is in netcdf-bin package - although it
should be in libnetcdf-dev (these are built by ubuntu).

Could the packagers add netcdf-bin as a dependency for gdal builds?


Long story:

netcdf-4 files use hdf5 format, but the netcdf driver should try to
open them first. If the file has nc/nc2/nc4/cdf suffix, the netcdf
driver tries to open the file, and if it fails then the hdf5 driver is
used.
Normally the netcdf driver is loaded before the hdf5 driver.

This works well on my builds, but it doesn't work with the ubuntugis builds.

I have traced the source of the problem to the build log at
https://launchpadlibrarian.net/122450487/buildlog_ubuntu-oneiric-amd64.gdal_1.9.2-2~oneiric6_BUILDING.txt.gz

===
checking for nc-config... no
        did not find nc-config, some features may be missing
        use --with-netcdf=/path/to/netcdf or add nc-config to PATH
checking for nc_open in -lnetcdf... yes
===

Proper output (which I get by building the same package from source using
===
checking for nc-config... /usr/bin/nc-config
checking libnetcdf compiler and linker flags with nc-config...
 got version="netCDF 4.1.1", prefix="/usr",
 libs="-L/usr/lib -lnetcdf", includedir="/usr/include"
checking for nc_open in -lnetcdf... yes
checking for netcdf-4 (and HDF5) support in libnetcdf... yes
===

The source of this error is that libnetcdf used for the build lacks nc-config.


Thanks,
Etienne

P.S.

You can try with the sample datasets in the gdal autotest :
autotest/gdrivers/data/trmm-nc4.nc

with gdal-1.9.2-2 from ubuntugis-unstable (oneiric):


$ gdalinfo /data/src/gdal/svn/branches/1.9/autotest/gdrivers/data/trmm-nc4.nc
Driver: HDF5Image/HDF5 Dataset
Files: /data/src/gdal/svn/branches/1.9/autotest/gdrivers/data/trmm-nc4.nc
Size is 40, 40

Forcing the use of the netcdf driver works (because libnetcdf does has
hdf5 support):

$ gdalinfo NETCDF:/data/src/gdal/svn/branches/1.9/autotest/gdrivers/data/trmm-nc4.nc
Warning 1: NetCDF driver detected file type=5, but libnetcdf detected type=3
Driver: netCDF/Network Common Data Format
Files: none associated
Size is 40, 40


with a custom build :

$ gdalinfo  NETCDF:/data/src/gdal/svn/branches/1.9/autotest/gdrivers/data/trmm-nc4.nc
Driver: netCDF/Network Common Data Format
Files: none associated
Size is 40, 40


More information about the Ubuntu mailing list