qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.41k stars 2.98k forks source link

[Mesh] Netcdf / ugrid(?) seems not to use crs? #47959

Open rduivenvoorde opened 2 years ago

rduivenvoorde commented 2 years ago

What is the bug or the crash?

Not really a bug, and I am aware that there is too much freedom in writing the metadata variables in netcdf

But I got a link mailed to these (4 Gb) model outputs in netcdf of the NorthSea:

https://noos.matroos.rws.nl/direct/get_netcdf.php?database=maps2d&source=dcsmv6_zunov4_zuno_kf_harmonie

While it is loaded by QGIS (little slow), it is not using crs from the file. While (see both screenies) loading it in Panoply it is apparently fine. Also found https://libraries.io/conda/ugrid-checks#basic-usage which can be used to check ugrids $ ugrid-checker ugrid.nc (it helped me to create a 'working' ugrid...

Note: not a bug, and it is very much possible that it is a data issue, but I thought maybe it is also a nice (public) dataset to do some optimization etc...

Screenshot-20220325085704-1417x704

Screenshot-20220325085923-1056x828

Steps to reproduce the issue

Download url Load as mesh in QGIS (coordinates in it are lat lon) Load world map (EPSG:4326)

Versions

master

Supported QGIS version

New profile

Additional context

No response

k-a-mendoza commented 7 months ago

Old issue but I'm having the same frustrations dealing with geospatial netcdf data. Many standardized models on the SAGE EMC-EarthModels page have multiple geospatial variables. latitude, longitude, depth, along with whatever field they're representing. In some cases, the geospatial coordinates are provided as northing or easting. In some cases there are many, many variables, such as density, vs, vp, q_factor, etc;... all with identical shapes to the geospatial coordinates.

Outside of QGIS, it is almost trivial to load, manipulate, and display desired slices at-will using a combination of xarray and matplotlib's pcolormesh. As long as you can define which coordinate or variable represents x and y, your desired scalar or vector field, and the CRS you're working in, all you have to do is:

1) load the coordinate data

2) transform it to desired CRS

3) plot it. matplotlib.pyplot.pcolormesh(xvar,yvar,loaded_xarray['variable_name'],**display_kwargs)

QGIS's reliance on MDAL means that netcdf's have to conform to a specific ordering standard which are quite opaque to those not familiar with C++ or how netcdf datafiles are structured. This means that the 3 step process outlined above is not possible to apply within QGIS. MDAL expects a specific internal variable file ordering, the lack of which has little effect when using the xarray+matplotlib approach.

This is unfortunate. I'm not sure what the takeaway should be from a dev standpoint, but my impressions are that it should not be this hard to get netcdf's to work given their ubiquity and ease of use in the python ecosystem.