7

I am trying to open a NetCDF file in QGIS. However it is not loading when I try to open it using Layer > Add Layer > Raster or even dragging and dropping it. I have also tried upgrading to master as suggested from this thread.

Here is the error message for 3.4-Madeira and 3.10-A Coruna

Invalid Layer: Raster layer Provider is not valid (provider: gdal, 
URI: C:/Users/~/Dec-Levels.nc

Here is the error message for 3.13.0-Master

Invalid Layer: Raster layer Provider is not valid (provider: gdal, URI: C:\Users\~\sa.nc 
(file: ..\..\..\src\core\raster\qgsrasterlayer.cpp row: 
618function QgsRasterLayer::setDataProvider:)

I am using Windows 10 64bit and used the 64bit installers for QGIS. I also used this example file: https://drive.google.com/open?id=1vtHc5GtDhUe2ENTkua8ihWqp6jYTHPBo

How can I resolve this?

3 Answers 3

7

As stated in the linked thread, QGIS (3.2+) can open the NetCDF file as a mesh layer.

(1) Open the file using Layer > Add Layer > Add Mesh Layer.

(2) By default, the first variable (Geopotential_level:250) will be plotted. Below is a short note to To view the variable you need.

  1. Open the Layer Properties (by right-clicking on the Dec-Levels layer on the Layers panel).
  2. On the Symbology tab, double click on the grey area at the right-hand-side of the desired variable to change it to rainbow square. You can also change the date/time by a slidebar/pulldown menu.

enter image description here

  1. Then click on [OK] or [Apply] button.

    enter image description here

3
  • Wow! Thank you so much!
    – Nikko
    Apr 6, 2020 at 13:13
  • The current latest version of QGIS is 3.18 but the answer suggests using a 3.2+ version, how this is possible?
    – Tekson
    Jun 20, 2021 at 4:02
  • @gis The sub-version number of QGIS 3 increases in a style like: 3.1, 3.2, 3.3, ... ... 3.18, ...
    – Kazuhito
    Jul 10, 2021 at 0:12
3

I downloaded the nc file. I check it with gdalinfo (from gdal utilities):

gdalinfo Dec-Levels.nc 
Driver: netCDF/Network Common Data Format
Files: Dec-Levels.nc
Size is 512, 512
Coordinate System is `'
Metadata:
  NC_GLOBAL#Conventions=CF-1.6
  NC_GLOBAL#history=2018-12-10 17:18:38 GMT by grib_to_netcdf-2.9.2: grib_to_netcdf /data/data03/scratch/50/46/_mars-atls00-a562cefde8a29a7288fa0b8b7f9413f7-X9jE61.grib -o /data/data05/scratch/5e/f4/_grib2netcdf-atls18-70e05f9f8ba4e9d19932f1c45a7be8d8-eDzoQH.nc -utime
Subdatasets:
  SUBDATASET_1_NAME=NETCDF:"Dec-Levels.nc":z
  SUBDATASET_1_DESC=[124x4x121x161] geopotential (16-bit integer)
  SUBDATASET_2_NAME=NETCDF:"Dec-Levels.nc":t
  SUBDATASET_2_DESC=[124x4x121x161] air_temperature (16-bit integer)
  SUBDATASET_3_NAME=NETCDF:"Dec-Levels.nc":q
  SUBDATASET_3_DESC=[124x4x121x161] specific_humidity (16-bit integer)
  SUBDATASET_4_NAME=NETCDF:"Dec-Levels.nc":w
  SUBDATASET_4_DESC=[124x4x121x161] lagrangian_tendency_of_air_pressure (16-bit integer)
  SUBDATASET_5_NAME=NETCDF:"Dec-Levels.nc":r
  SUBDATASET_5_DESC=[124x4x121x161] relative_humidity (16-bit integer)
  SUBDATASET_6_NAME=NETCDF:"Dec-Levels.nc":u
  SUBDATASET_6_DESC=[124x4x121x161] eastward_wind (16-bit integer)
  SUBDATASET_7_NAME=NETCDF:"Dec-Levels.nc":v
  SUBDATASET_7_DESC=[124x4x121x161] northward_wind (16-bit integer)
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)

It looks OK. Then I load all layers (seven layers) into QGIS 3.12 without any error:

enter image description here

I suppose your file had some defect during downloading. Test the downloaded file with gdalinfo (you can start it for osgeo4w shell window). You should also check in case of error if your gdal version supports netCDF:

gdalinfo --formats
Supported Formats:
VRT -raster- (rw+v): Virtual Raster
DERIVED -raster- (ro): Derived datasets using VRT pixel functions
GTiff -raster- (rw+vs): GeoTIFF
... very log list ...
netCDF -raster,vector- (rw+s): Network Common Data Format
...

I tested on Ubuntu 18.04 Linux, gdal 2.2.3 and QGIS 3.12.1

-1

You can simply drag and drop the file in QGIS. It will automatically ask for the variable to be plotted. It worked for me.

1
  • 1
    OP already said that drag and drop didn't work. Sep 24, 2020 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.