I have some results from a simulation in Delft3D that I'd like to visualise as a mesh in QGIS. For example, I'd like to see the change in water level at a different time step in the domain. The file is available here (https://www.dropbox.com/s/z5hicbxl2106evk/trim-tst.nc?dl=0). I've tried every way to import it, but all the times the layer SR doesn't match with the original one.
Basically, QGIS takes as the map extension the number of cells in the two directions instead of latitude and longitude. So, instead of being like this (set of data in front of Edinburgh), with the correct EPSG 4326:
It appears as:
The file is originally a NEFIS file which can be converted to a NetCDF file through the Delft3D OpenEarthTools (in particular the command 'vs_trim2nc'). I've seen in the guide that the software requires the attribute "grid_mapping" to define the extension, but in this case I have a NetCDF CF1.6.
In here you can see what I get from 'gdalinfo myfile.nc' in the OSGeo4W Shell:
>gdalinfo trim-tst.nc Warning 1: Recode from UTF-8 to CP_ACP failed with the error: "Invalid argument". Driver: netCDF/Network Common Data Format Files: trim-tst.nc trim-tst.nc.aux.xml Size is 512, 512 Coordinate System is `' Metadata: NC_GLOBAL#comment= NC_GLOBAL#Conventions=CF-1.6 NC_GLOBAL#delft3d_description= NC_GLOBAL#disclaimer=This data is made available in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. NC_GLOBAL#email= NC_GLOBAL#geospatial_lat_max=56.28970336914063 NC_GLOBAL#geospatial_lat_min=55.91470336914063 NC_GLOBAL#geospatial_lat_units=dergees_north NC_GLOBAL#geospatial_lon_max=-2.179219245910645 NC_GLOBAL#geospatial_lon_min=-3.374219179153442 NC_GLOBAL#geospatial_lon_units=dergees_east NC_GLOBAL#geospatial_vertical_max=68.13890075683594 NC_GLOBAL#geospatial_vertical_min=-146.2114105224609 NC_GLOBAL#geospatial_vertical_positive=down NC_GLOBAL#geospatial_vertical_units=m NC_GLOBAL#history=Original filename: trim-tst.dat, Deltares, FLOW2D3D Version 6.01.11.65625, Dec 11 2019, 13:09:41, file version: 3.54.30, file date:2021-02-10 18:53:23, transformation to netCDF: $HeadURL: https://svn.oss.deltares.nl/repos/openearthtools/trunk/matlab/applications/delft3d/vs_trim2nc.m $ $Id: vs_trim2nc.m 13203 2017-03-08 16:03:11Z ymzkala.x $ NC_GLOBAL#institution= NC_GLOBAL#references=http://svn.oss.deltares.nl NC_GLOBAL#source=Delft3D trim file NC_GLOBAL#terms_for_use=These data can be used freely for research purposes provided that the following source is acknowledged: NC_GLOBAL#time_coverage_end=2021-02-11T00:00 NC_GLOBAL#time_coverage_start=2021-02-10T00:00 NC_GLOBAL#title=NetCDF created from NEFIS-file trim-tst.dat NC_GLOBAL#version=Deltares, FLOW2D3D Version 6.01.11.65625, Dec 11 2019, 13:09:41, file version: 3.54.30 Subdatasets: SUBDATASET_1_NAME=NETCDF:"trim-tst.nc":time_bounds SUBDATASET_1_DESC=[2x25] time_bounds (64-bit floating-point) SUBDATASET_2_NAME=NETCDF:"trim-tst.nc":longitude SUBDATASET_2_DESC=[242x78] longitude (32-bit floating-point) SUBDATASET_3_NAME=NETCDF:"trim-tst.nc":latitude SUBDATASET_3_DESC=[242x78] latitude (32-bit floating-point) SUBDATASET_4_NAME=NETCDF:"trim-tst.nc":grid_longitude SUBDATASET_4_DESC=[242x78x4] longitude (32-bit floating-point) SUBDATASET_5_NAME=NETCDF:"trim-tst.nc":grid_latitude SUBDATASET_5_DESC=[242x78x4] latitude (32-bit floating-point) SUBDATASET_6_NAME=NETCDF:"trim-tst.nc":grid_depth SUBDATASET_6_DESC=[243x79] sea_floor_depth_below_sea_level (32-bit floating-point) SUBDATASET_7_NAME=NETCDF:"trim-tst.nc":depth SUBDATASET_7_DESC=[242x78] sea_floor_depth_below_sea_level (32-bit floating-point) SUBDATASET_8_NAME=NETCDF:"trim-tst.nc":zactive SUBDATASET_8_DESC=[242x78] zactive (32-bit floating-point) SUBDATASET_9_NAME=NETCDF:"trim-tst.nc":area SUBDATASET_9_DESC=[242x78] cell_area (32-bit floating-point) SUBDATASET_10_NAME=NETCDF:"trim-tst.nc":waterlevel SUBDATASET_10_DESC=[25x242x78] sea_surface_height (32-bit floating-point) SUBDATASET_11_NAME=NETCDF:"trim-tst.nc":velocity_x SUBDATASET_11_DESC=[25x1x242x78] eastward_sea_water_velocity (32-bit floating-point) SUBDATASET_12_NAME=NETCDF:"trim-tst.nc":velocity_y SUBDATASET_12_DESC=[25x1x242x78] northward_sea_water_velocity (32-bit floating-point) SUBDATASET_13_NAME=NETCDF:"trim-tst.nc":tau_x SUBDATASET_13_DESC=[25x242x78] surface_downward_northward_stress (32-bit floating-point) SUBDATASET_14_NAME=NETCDF:"trim-tst.nc":tau_y SUBDATASET_14_DESC=[25x242x78] surface_downward_eastward_stress (32-bit floating-point) Corner Coordinates: Upper Left ( 0.0, 0.0) Lower Left ( 0.0, 512.0) Upper Right ( 512.0, 0.0) Lower Right ( 512.0, 512.0) Center ( 256.0, 256.0)
I also tried to import just the subdataset I need, but with the same result as above.
I've also read about the NetCDF operators (NCO), available at this link: http://nco.sourceforge.net/src/ I've tried to use the pre-built executable on Anaconda for Windows, but I found lots of difficulties on using them. As you can imagine, I'm a noob in programming and in particular in Python, so it's quite hard for me to create a script useful for my purpose.
PS: I'm working on Windows10 on QGIS 3.16.3-Hannover (or in case of the version 3.4 Madeira)
UPDATE: I also tried to use gdalwarp unsuccessfully.
gdalwarp -geoloc NETCDF:trim-tst.nc:waterlevel wl.nc Warning 1: Recode from UTF-8 to CP_ACP failed with the error: "Invalid argument". Warning 1: dimension #2 (n) is not a Longitude/X dimension. Warning 1: dimension #1 (m) is not a Latitude/Y dimension. Warning 1: Several drivers matching nc extension. Using NETCDF Warning 1: Recode from UTF-8 to CP_ACP failed with the error: "Invalid argument". Warning 1: dimension #1 (n) is not a Longitude/X dimension. Warning 1: dimension #0 (m) is not a Latitude/Y dimension. Warning 1: Recode from UTF-8 to CP_ACP failed with the error: "Invalid argument". Warning 1: dimension #1 (n) is not a Longitude/X dimension. Warning 1: dimension #0 (m) is not a Latitude/Y dimension. ERROR 1: Int overflow : -nan(ind) x -nan(ind)
The command try to read m,n as lat/lon, but actually they are the name of the cells given from Delft3D in the two directions.