How to convert a NetCDF file TIFF to import in QGIS 3.x

NetCDF is a data format and library designed to store multidimensional arrays of scientific data.
If you try to load it in Qgis, probably you will get the following message:

Invalid Layer: GDAL provider Cannot open GDAL dataset file.nc' not recognized as a supported file format. Raster layer Provider is not valid (provider: gdal, URI: file.nc

In QGIS 2.x you can use NetCDF plugin to load the layer, but it not exist yet in QGIS 3.x
To import the layer you need to convert the .nc file to another like .tiff

To do it, you can use gdal toolkit as follows:

gdal_translate file.nc file.tiff 
Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Input file contains subdatasets. Please, select one of them for reading.

This issue is because the .nc contains subdatasets and you must specify only one.

To see the subdatasets names just execute the following sentence in your terminal:

gdalinfo file.nc

Subdatasets:
  SUBDATASET_1_NAME=NETCDF:"FWI.GPM.LATE.v5.Monthly.Default.201903.nc":GPM.LATE.v5_DC
  SUBDATASET_1_DESC=[1x1330x3600] GPM.LATE.v5_DC (32-bit floating-point)
  SUBDATASET_2_NAME=NETCDF:"FWI.GPM.LATE.v5.Monthly.Default.201903.nc":GPM.LATE.v5_DMC
  SUBDATASET_2_DESC=[1x1330x3600] GPM.LATE.v5_DMC (32-bit floating-point)
 
As you see the .nc file contains two subdatasets. To convert the last one, just execute:

gdal_translate NETCDF:"FWI.GPM.LATE.v5.Monthly.Default.201903.nc":GPM.LATE.v5_DMC file.tiff
Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Input file size is 3600, 1330
0...10...20...30...40...50...60...70...80...90...100 - done.

If you want more information about your .nc file, just execute:

ncdump -h file.nc 

Enjoy it!

Comments

Popular posts from this blog

How to fix Android when developer options are not available for this user

Exception: Could not find a default OpenFlow controller in Mininet

v4l2: open /dev/video0: Permission denied