Closed moovida closed 2 years ago
The way which ncWMS handles grids like this is via 2d lat-lon coordinate variables, as per https://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#_two_dimensional_latitude_longitude_coordinate_variables
Notably it completely ignores any other definition of the coordinate system.
We use Unidata's NetCDF-Java libraries for doing this projection, and it's a very stable longstanding part of the system, so I would guess that the data you are using doesn't define its coordinate variables in this standard way (which is not especially uncommon - many data providers use ad hoc mechanisms which supply all of the necessary data, just not in a way which follows the CF conventions).
If you can send me a sample dataset I'd be happy to take a look and see if this is the case. If so the only practical solution is to rewrite your coordinate variables so that they refer to the correct area.
Hy @guygriffiths , thanks for you reply. I though it might be as you describe it. I tried some other applications (panolpy for example) and they have the exact same issue, I guess the netcdf java libs just do not read these non standard ways of defining the prj (as you can se above, some have a WKT, others just the name).
If I can, I would love to send you the samples (placing the link here below, since they are quite big) and hear your best practice on how to solve it to make it work properly. I am not sure if you mean that one could insert some sort of plugin to ncWMS to tweak the metadata or if it is more about a preprocessing of the data. Either way, thank you.
Link to the data: https://we.tl/t-cOgpRXJhWU
Thanks for sending me that. I think I've identified what the issue is. The coordinates are actually defined correctly, in the 2d coordinate variable lat
and lon
. The data is also correctly identifying these as the coordinates to use via the coordinates
attribute. However, because your dimensions are named rlat
/rlon
and you also have these defined as variables with the units degrees
, they are being seen as coordinate variables and used in preference to the 2d versions.
The way to fix it is to make sure that rlat
and rlon
are not coordinate variables, but just standard ones. That means they need to have a different name to the dimensions. If you have the NetCDF Operators, you can rename them using this command:
ncrename -v rlon,rotatedlon -v rlat,rotatedlat file.nc
If you prefer not to modify the data, you can use NcML, a markup language which ncWMS supports, to wrap your data files and rename the variables without touching the data itself. Create a file named filename.ncml
in the same directory with the contents:
<?xml version="1.0" encoding="UTF-8"?>
<netcdf location="filename.nc"
xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
<variable name="rotatedlon" orgName="rlon" type="float"/>
<variable name="rotatedlat" orgName="rlat" type="float"/>
</netcdf>
(you will need to change the line containing filename.nc
, obviously)
Then you can simply point ncWMS at this file instead of the original data file and it will work.
Note that I've actually only tried this with one dataset - the african one - because I'm currently WFH and my internet connection is pretty slow. It worked for that though, so I imagine the problem is the same for all of the datasets. Let me know how you get on.
Dear @guygriffiths , thanks a ton for the fast reply and sorry for my late reply, been knocked out by a flue. I never used the netcdf operator, so that will be my first choice to try to set the datasets straight. Great!
Actually compilation of the operators seems more tricky than expected. And I have to admit that the ncml trick is just great. And does work. Thank you for bearing with me and helping even if, obviously, it was not a problem of ncWMS. I will close the issue.
Hello, I am not sure if this is more a question or an issue. Trying to describe it.
I got a couple of netcdf cordex meteo datasets of various cordex domains: https://cordex.org/data-access/regional-climate-change-simulations-for-cordex-domains/
While for example the European region looks ok to me:
the African is placed between Australia and America:
But then again another European gets misplaced (you can see Italy's boot shifted east:
Is there any way to make ncWMS understand what is going on with the projections? In the above examples I see two rotated pole projections with diverse parameters and one lambert conformal. But only the first is properly identified.
Thanks for any hint you can give me.
PS: For completeness I report the relevant information about the projection and metadata that gdal is able to read out of the datasets.
Europe Right:
Africa wrong:
Europe wrong: