0

I am trying to open these NetCDF files in QGIS: https://dustcomm.atmos.ucla.edu/data/K21b/ (They are for atmospheric dust). They do not load correctly (I tried Add Layer > Add Mesh and Add Raster).

I get the vertical line problem described in a similar post, which seems to be because QGIS is not reading the variables correctly (namely, lat and long):

I tried to follow the solution suggested by @Kazuhito: I installed the NCO tools and am able to look at the contents of the files. However, when I try to change the order of the variables, the files still have the same error. This is what I tried:

ncpdq -a Mean,Median,Neg1sigma,Neg2sigma,Pos1sigman,Pos2sigma,bin_D_lower,bin_D_upper,lat,lon,source originalFile.nc newFile.nc

As far as I can tell, these are the variables in the file but it does not work.

What command do I need to use to correctly assign the variables and open this file in QGIS?

1
  • 1
    Rather than reorder the variables in the file, ncpdq reorders the dimensions of the variable, which is what you need, since the vertical line is the plotting the vertical line as source x lon for one of the lats, rather than lat x lon for one of the sources. You need to reorder the storage order within the variables from lat X lon X source into source X lat X lon. Also, the 'units' attribute names seem improperly capitalized to "Units" which might confuse things too.
    – Dave X
    Oct 14, 2021 at 21:38

1 Answer 1

1

Here's an ncdump of the data structure of a file from your helpful link:

ncdump -h ~/Downloads/DustCOMM_source_region_DAOD_annual_PM2_5_abs.nc                                      

netcdf DustCOMM_source_region_DAOD_annual_PM2_5_abs {
dimensions:
    source = 9 ;
    diameter = 6 ;
    lat = 96 ;
    lon = 144 ;
variables:
    double source(source) ;
        source:Description = "Source region: 1 = western N. Afr., 2 = eastern N. Afr., 3 = S. Sahara & Sahel, 4 = Middle East & C. Asia, 5 = Australia, 6 = N. America, 7 = E. Asia, 8 = S. America., 9 = S. Africa" ;
        source:Units = "DAOD (dimensionless)" ;
    double bin_D_lower(diameter) ;
        bin_D_lower:Description = "Lower bin boundary" ;
        bin_D_lower:Units = "um" ;
    double bin_D_upper(diameter) ;
        bin_D_upper:Description = "Upper bin boundary" ;
        bin_D_upper:Units = "um" ;
    double lat(lat) ;
        lat:Description = "Longitude" ;
        lat:Units = "Degrees north" ;
    double lon(lon) ;
        lon:Description = "Longitude" ;
        lon:Units = "Degrees east" ;
    double Median(lat, lon, source) ;
        Median:Description = "Median annual contribution of each source region to annualDAOD from PM2.5 dust" ;
        Median:Units = "dimensionless" ;
    double Mean(lat, lon, source) ;
        Mean:Description = "Mean annual contribution of each source region to annualDAOD from PM2.5 dust" ;
        Mean:Units = "dimensionless" ;
    double Neg1sigma(lat, lon, source) ;
        Neg1sigma:Description = "Neg1sigma annual contribution of each source region to annualDAOD from PM2.5 dust" ;
        Neg1sigma:Units = "dimensionless" ;
    double Pos1sigman(lat, lon, source) ;
        Pos1sigman:Description = "Pos1sigman annual contribution of each source region to annualDAOD from PM2.5 dust" ;
        Pos1sigman:Units = "dimensionless" ;
    double Neg2sigma(lat, lon, source) ;
        Neg2sigma:Description = "Neg2sigma annual contribution of each source region to annualDAOD from PM2.5 dust" ;
        Neg2sigma:Units = "dimensionless" ;
    double Pos2sigma(lat, lon, source) ;
        Pos2sigma:Description = "Pos2sigma annual contribution of each source region to annualDAOD from PM2.5 dust" ;
        Pos2sigma:Units = "dimensionless" ;
}

You are getting the vertical line because QGIS Mesh is plotting the data as source X lon for one of the lats, rather than lat x lon for one of the sources.

QGIS's Mesh tool depends on CF/COARDS conventions, and the storage order within the variables matter. See https://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/ch02s04.html

Rather than reorder the variables in the file, ncpdq reorders the dimensions (and storage order) of the data in the variables in the file.

You need to reorder the storage order within the variables from lat X lon X source into source X lat X lon. (Also, the 'units' attribute names seem improperly capitalized to "Units" which might confuse things too.)

The ncpdq command to change the storage order so the "source" coordinate is first/slowest changing is:

ncpdq -a source,lat,lon -O DustCOMM_source_region_DAOD_annual_PM2_5_abs.nc junk.nc

Then you get a more reasonable plot of the Mean variable for Source=1 with QGIS's Add Layer/Add Mesh Layer/(choose data)/Add procedure:

enter image description here

If then you go into Layer Properties/Symbology and select the hammer/screwdriver icon, you could choose different variables X source to use for the layer by clicking their colored checkbox.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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