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:
Yet Panoply projects the raster as intended:
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" ;
}