1

I have created a NetCDF mesh with u and v variables for velocity. I can load it onto QGIS 3.14 as a mesh layer. The variables are not recognized as vector though (isVector : No is displayer in group metadata) so I'm unable to display arrows, streamlines etc. I have created the .nc file with NetCDF4-python. The properties of my metadata are:

{'time': <class 'netCDF4._netCDF4.Variable'>
float64 time(time)
    axis: T
    standard_name: time
    time_origin: 18-MAR-2020 00:00:00
    units: seconds since 2020-03-18T00:00:00
unlimited dimensions:
current shape = (101,)
filling on, default _FillValue of 9.969209968386869e+36 used, 'lat': <class 'netCDF4._netCDF4.Variable'>
float64 lat(lat)
    axis: Y
    units: degrees_north
unlimited dimensions:
current shape = (330,)
filling on, default _FillValue of 9.969209968386869e+36 used, 'lon': <class 'netCDF4._netCDF4.Variable'>
float64 lon(lon)
    axis: X
    units: degrees_east
unlimited dimensions:
current shape = (305,)
filling on, default _FillValue of 9.969209968386869e+36 used, 'u': <class 'netCDF4._netCDF4.Variable'>
float64 u(time, lat, lon)
    long_name: u_velocity component
    standard_name: eastward_flood_water_velocity
    units: meter second-1
unlimited dimensions:
current shape = (101, 330, 305)
filling on, default _FillValue of 9.969209968386869e+36 used, 'v': <class 'netCDF4._netCDF4.Variable'>
float64 v(time, lat, lon)
    long_name: v_velocity component
    standard_name: northward_flood_water_velocity
    units: meter second-1
unlimited dimensions:
current shape = (101, 330, 305)
filling on, default _FillValue of 9.969209968386869e+36 used}

I have downloaded another .nc dataset I found on this blog https://opengislab.com/blog/2020/10/10/wind-vector-mapping-and-animation-in-qgis and funnily enough I can display arrows on it. The properties for this .nc file is:

{'time': <class 'netCDF4._netCDF4.Variable'>
float64 time(time)
    _CoordinateAxisType: Time
    actual_range: [1.6015104e+09 1.6020288e+09]
    axis: T
    calendar: proleptic_gregorian
    ioos_category: Time
    long_name: Forecast time for ForecastModelRunCollection
    missing_value: nan
    standard_name: time
    time_origin: 01-JAN-1970 00:00:00
    units: seconds since 1970-01-01T00:00:00Z
unlimited dimensions:
current shape = (49,)
filling on, default _FillValue of 9.969209968386869e+36 used, 'depth': <class 'netCDF4._netCDF4.Variable'>
float32 depth(depth)
    _CoordinateAxisType: Height
    _CoordinateZisPositive: down
    actual_range: [10. 10.]
    axis: Z
    ioos_category: Location
    long_name: Depth
    positive: down
    standard_name: depth
    units: m
unlimited dimensions:
current shape = (1,)
filling on, default _FillValue of 9.969209968386869e+36 used, 'latitude': <class 'netCDF4._netCDF4.Variable'>
float32 latitude(latitude)
    _CoordinateAxisType: Lat
    actual_range: [18.167128 23.049076]
    axis: Y
    ioos_category: Location
    long_name: Latitude
    standard_name: latitude
    units: degrees_north
unlimited dimensions:
current shape = (137,)
filling on, default _FillValue of 9.969209968386869e+36 used, 'longitude': <class 'netCDF4._netCDF4.Variable'>
float32 longitude(longitude)
    _CoordinateAxisType: Lon
    actual_range: [-159.0599  -154.17369]
    axis: X
    ioos_category: Location
    long_name: Longitude
    standard_name: longitude
    units: degrees_east
unlimited dimensions:
current shape = (128,)
filling on, default _FillValue of 9.969209968386869e+36 used, 'temp': <class 'netCDF4._netCDF4.Variable'>
float32 temp(time, depth, latitude, longitude)
    _FillValue: nan
    colorBarMaximum: 27.0
    colorBarMinimum: 23.0
    coordinates: time_run time depth lat lon
    ioos_category: Temperature
    long_name: potential temperature
    missing_value: nan
    standard_name: sea_water_potential_temperature
    units: Celsius
unlimited dimensions:
current shape = (49, 1, 137, 128)
filling on, 'salt': <class 'netCDF4._netCDF4.Variable'>
float32 salt(time, depth, latitude, longitude)
    _FillValue: nan
    colorBarMaximum: 36.0
    colorBarMinimum: 33.0
    coordinates: time_run time depth lat lon
    ioos_category: Salinity
    long_name: salinity
    missing_value: nan
    standard_name: sea_water_salinity
    units: 1e-3
unlimited dimensions:
current shape = (49, 1, 137, 128)
filling on, 'u': <class 'netCDF4._netCDF4.Variable'>
float32 u(time, depth, latitude, longitude)
    _FillValue: nan
    colorBarMaximum: 0.15
    colorBarMinimum: -0.15
    coordinates: time_run time depth lat lon
    ioos_category: Currents
    long_name: u-velocity component
    missing_value: nan
    standard_name: eastward_sea_water_velocity
    units: meter second-1
unlimited dimensions:
current shape = (49, 1, 137, 128)
filling on, 'v': <class 'netCDF4._netCDF4.Variable'>
float32 v(time, depth, latitude, longitude)
    _FillValue: nan
    colorBarMaximum: 0.15
    colorBarMinimum: -0.15
    coordinates: time_run time depth lat lon
    ioos_category: Currents
    long_name: v-velocity component
    missing_value: nan
    standard_name: northward_sea_water_velocity
    units: meter second-1
unlimited dimensions:
current shape = (49, 1, 137, 128)
filling on}

Here they use an extra dimension called depth. I don't really need that though. I would also like to know which variable attributes are important if at all.

I saw a similar question to this posted before on Create a flow vector NetCDF from X and Y velocity components. Apparently the question was answered on chat but I can't see the answer.

Any hint?

2 Answers 2

1

I figured it out! The long name attributes u_velocity component and y_velocity component had to be changed to u-velocity component and v-velocity component respectively.

0

QGIS uses MDAL library for reading the NetCDF data. Depending of MDAL driver that is used, there is a hardcoded logic how to determine is dataset is vector or not. For example for NetCDF GDAL driver or for UGRID NetCDF. So you need to use for example u-velocity component and v-velocity component for long name.

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.