YAXArrays.jl
YAXArrays.jl copied to clipboard
Can't open Netcdf file in QGIS when categorical axes is first dimension
I have problems opening the result in QGIS, when I save the following cube as a netcdf:
YAXArray with the following dimensions
PeakStats Axis with 2 elements: Min Max
Y Axis with 5820 Elements from 561609.15 to 736179.15
X Axis with 7500 Elements from 9.48724066e6 to 9.26227066e6
Total size: 333.02 MB
The save works and it also has values in it, because I can reload it correctly with YAXArrays, but when I try to open it in QGIS, it can't be displayed, because QGIS tries to open the X axis as band information. The same happens with ncview.
I am not sure, whether this is an issue in YAXArray or whether this is a limitation of QGIS, but at least we should document it. I can mitigate the problem by permuting the dimensions, so that Y is the first and X is the second axis. And I think, that it would be good, when the axes would be permuted automatically while writing the netcdf file
If this is about dimension order, does it help to save a permuted cube, i.e. savecube(permutedims(c,(2,3,1)))?
Yes it does. I think it would be good to apply the permutation of the dimension order automatically so that a user doesn't have to think about this. But then I am not quite sure, where we would have to apply this permutation.
We did this in the past in exportcube when this was still separate from savecube. There, names like lon, lat and time had a special meaning and would result in an automatic permutation. I am not sure if we should do this here, wouldn't it contradict the "all axes are equal" principle?
Could we do this only in the NetCDF backend? Because sure all axes are equal, but then the resulting NetCDF is not usable in other software anymore. And also the user might not be aware, that the dimensions are permuted. The example cube started with a dimensional layout of (Y,X, Time) and has been permuted in between by YAXArrays. I don't know enough of the inner layout of a NetCDF to see, what changes, when we save the permuted dims.
It might be enough to document it and make the user aware of this.