2

I want to write data to a NetCDF file with an irregular rotated lat-lon coordinate grid and open it in QGIS. The data is on an irregular grid which follows a satellite swath. The grid is irregular in the sense that the distances between points can vary. Basically, I have a matrix of wind speed values ws10 at certain latitude and longitude coordinates. How do I properly save these ws10(lat, lon) to a NetCDF file, so that they can be viewed in QGIS projected on a world map?

This is what my NetCDF file header currently looks like:

netcdf waves {
dimensions:
        y = 52 ;
        x = 60 ;
variables:
        float lat(y, x) ;
                lat:standard_name = "latitude" ;
                lat:long_name = "latitude" ;
                lat:units = "degrees_north" ;
        float lon(y, x) ;
                lon:standard_name = "longitude" ;
                lon:long_name = "longitude" ;
                lon:units = "degrees_east" ;
        float ws10(y, x) ;
                ws10:long_name = "Wind Speed at 10 m" ;
                ws10:units = "meters per second" ;
                ws10:coordinates = "lon lat" ;
}

If I open the file in QGIS and add it as a raster or mesh layer (based on Dave X's comment) it takes the x-y-indices as coordinates. For some reason the grey-scale raster layer is flipped: QGIS screenshot

Yet Panoply projects the raster as intended: Panoply screenshot Based on other questions, I have tried to add the CRS information to the file as shown below, but QGIS still uses the x-y-grid. How can this be solved?

netcdf test_man {
dimensions:
        y = 52 ;
        x = 60 ;
variables:
        int crs ;
                crs:spatial_ref = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_84\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.017453292519943295]]" ;
                crs:grid_mapping_name = "latitude_longitude" ;
                crs:longitude_of_prime_meridian = 0. ;
                crs:semi_major_axis = 6378137. ;
                crs:inverse_flattening = 298.257223563 ;
        float lat(y, x) ;
                lat:standard_name = "latitude" ;
                lat:long_name = "latitude" ;
                lat:units = "degrees_north" ;
        float lon(y, x) ;
                lon:standard_name = "longitude" ;
                lon:long_name = "longitude" ;
                lon:units = "degrees_east" ;
        float ws10(y, x) ;
                ws10:long_name = "Wind Speed at 10 m" ;
                ws10:units = "meters per second" ;
                ws10:coordinates = "lon lat" ;
                ws10:grid_mapping = "crs" ;
}
2
  • Maybe try `Layer/Add layer/Add Mesh layer'?
    – Dave X
    Dec 15, 2020 at 23:15
  • I have replaced the QGIS screenshot in the question. As you can see, it still uses x-y instead of lat-lon when added as a mesh layer. But I realize now that the raster layer (grey) is flipped vertically. Dec 16, 2020 at 9:39

1 Answer 1

2

I suggest using UGRID Convention NetCDF format to be fully supported by QGIS Mesh Layer, where you need to define your grid elements. Examples can be found in MDAL test suite. MDAL is C++ Library that QGIS uses to read the data for Mesh Layer.

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.