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.52k stars 2.99k forks source link

[Mesh] Netcdf (.nc) not showing values anymore? #47908

Closed rduivenvoorde closed 2 years ago

rduivenvoorde commented 2 years ago

What is the bug or the crash?

Hunting a non-QGIS related bug we created a tiny netcdf: 5x6 values

But loading that nc file (as a mesh file) does not show any value except one?

It is loaded ok, temporal controller is ok, but whatever styling I use it only shows the upper right cell...

Below the first timestep in Panoply:

Screenshot-20220322111025-1028x704

Or showing in ncdump:

 _, _, _, _, _,
  _, 0, _, _, _,
  _, _, 0.3333333, _, _,
  _, _, 0.3333333, _, _,
  _, _, _, _, _,
  _, _, _, _, _,

QGIS only showing:

Screenshot-20220322111238-484x474

which looks like it is value 0.83, a value of one of the last steps?

Is the dataset wrong (other/larger sets work)? Or is it that QGIS does not work with such tiny sets?

Steps to reproduce the issue

This zip contains a directory with 'mercator.zip' and another directory with the same data as ascii-grid files:

klein.zip

If anybody has a clue what I'm doing wrong please let me know...

Versions

3.22 and current master no Linux 3.16 on Windows

Supported QGIS version

New profile

Additional context

The idea is to use the nc file instead of the grids

vcloarec commented 2 years ago

@rduivenvoorde , I think everything is ok. Indeed for mesh layer, each cell of the nc file is related to a vertex of the mesh layer, and what we see in the QGIS rendering is the interpolation between vertices. In you file, at the beginning, there is only 2 vertices with value, so the face, that need the value of all its vertices, can't be rendered until all the vertices have value. Once, the for vertices of the top right face have valid values, the face is rendered, but only one face for 4 values.

rduivenvoorde commented 2 years ago

@vcloarec ah, so QGIS is ALWAYS interpolating values/looking around? Not taking no-data into account. So I updated the netcdf to have a 0 as value everywhere there is no outcome:

nc.zip

Indeed THEN you will see something everywhere. Only the centre cells have 0.33 as value now:

Screenshot-20220323110336-1218x735

But (as we come from asc grid data) we are wondering if you can make QGIS to NOT interpolate, and for example use the lowerleft corner to color a 'cell', OR have some setting in which we tell QGIS: use the grid values as 'faces' (without interpolation)..

For reference I also included the asc file which you see here on top of the nc with the same values (except 0 is colored bleu there)...

Screenshot-20220323110755-1219x726

I wonder if we could use nc files to be visualized as raster-cells, and without interpolation of values? Is that uncommon? Would that be doable?

saberraz commented 2 years ago

Hi Richard,

Is it not the Resampling method switch under mesh rendering settings: image

rduivenvoorde commented 2 years ago

@saberraz thanks Saber, we are looking at data:

 estimated_time_of_arrival =
  0, 0, 0, 0, 0,
  0, 0, 0, 0, 0,
  0, 0, 0.3333333, 0, 0,
  0, 0, 0.3333333, 0, 0,
  0, 0, 0, 0, 0,
  0, 0, 0, 0, 0,

Whatever setting I use, it never looks like a grid (see below). So my question is: IS this feasible? If we would provide some budget, would it be possible to make QGIS visualize a netcdf just like a grid? OR is this really a silly use of netcdf/mesh?

QGIS mentions somewhere: that it mesh type are faces, but datatype is vertices:

Screenshot-20220323113751-400x129

Wondering if we could QGIS visualize a true grid based on netcdf?

Below is what I can make of it now, but maybe I'm missing something?

Screenshot-20220323113502-771x585

Screenshot-20220323113402-801x575

Screenshot-20220323113419-780x567

This is a without resampling, clicking in the map. Is it still resamping there? Should show 0.3333 I think?

Screenshot-20220323114149-775x529

PeterPetrik commented 2 years ago

Hi Richard, mesh type is probably more of 1d/2d/3d split. The data type is if the data is defined on vertices or faces. For data on vertices, you need all values defined to be able to render the "face/cell" color == style the cell. For data on faces, you either have data on the face or not. The resampling brings a bit of confusion to the equations, but for example if your data are on defined on cell, but you want to have smooth style, you can resample them on-the-fly to vertices and have the smooth styling (not pixelated). It works vice-versa too.

rduivenvoorde commented 2 years ago

@PeterPetrik Thanks for this information! But then next question would be: what to add to the NetCDF to tell QGIS (or is it MDAL?) that Data type is faces? Looking into the data with Panoply or ncinfo I do not see any (meta)data pointing to such? Is there a magic spell to do this? AND if I do so: will QGIS then render face/cell's? Or would this need some work in QGIS or MDAL? Thanks for any info!

PeterPetrik commented 2 years ago

if you have full control of the file you want to output, it is best to create http://ugrid-conventions.github.io/ugrid-conventions/#data-variables file instead of "some netcdf"

Since netcdf is read by netCDF -> GDAL -> MDAL -> Mesh Layer but ugrid convention is UGRID -> MDAL -> Mesh Layer. I am not sure if "GDAL" read netCDF can be defined on faces.

rduivenvoorde commented 2 years ago

Ok, will read into this. We have full control over how to build them up: it is not 'some netcdf' type we are creating :-)

I was trying to create netcdf files which should be usable in Geoserver/Mapserver AND QGIS (server), Docs of geoserver talk about "gridded NetCDF files having dimensions following the COARDS convention" other docs are talking about CF-1.6 conventions... so I thought that was what we needed... and that is what we were creating and feeding to QGIS... The files we are creating now were readable in (if I am correct) geoserver, but I can be wrong.

Any pointers to examples of ugrid file which we can use to peek into the innumerable amount attributes a netcdf can have...?

Googled https://www.mdal.xyz/drivers/ugrid.html with so many drivers... Don't know where to begin.

PeterPetrik commented 2 years ago

CF-1.6 is OK convention, but we do not support it natively at the moment in MDAL. CF-1.6 is without topology. UGRID is CF-1.6. "extension" that defines topology for your mesh, so you can define how cells are created and their shapes etc.

PeterPetrik commented 2 years ago

here are some samples: https://github.com/lutraconsulting/MDAL/tree/master/tests/data/ugrid but easier is probably to just follow official docs: http://ugrid-conventions.github.io/ugrid-conventions/#data-variables

rduivenvoorde commented 2 years ago

@PeterPetrik Thanks!!! Those ugrids are nice! Though a little more complex to write if you have to create the topology yourself...

But I have a working minimal example based on one you deltares examples. Have to look what is the best way to handle our data: face or vertex based...

Will close this one.