I was wondering if anyone has encountered NetCDFs being mapped in the "wrong" location by QGIS? I'm using QGIS 3.16 and I've tried 2.18 too. I think the problem has to do with the longitude units of the NetCDF being in degrees east and QGIS not understanding how to deal with them properly. When I add other layers (vector or raster) they map correctly to my area of interest (British Columbia). My map display is set to WGS 84 (EPSG: 4326) and I import my file.nc as a mesh layer (I've tried raster too but it doesn’t make a difference) and set the CRS of the mesh layer to WGS 84 (4326) too after it has been imported. The NetCDF file imports and visualizes without any problems, it is just in the wrong place (i.e. it doesn’t appear anywhere near my study area. When I zoom into the mesh layer, The Coordinate box at the bottom of the display gives the longitude (degrees east, approx. 225), latitude (approx 50), and then when I zoom to a vector layer in my study area the coordinate box shows the longitude (approx.-128) and latitude (approx. 50).

I don't think the problem lies with the NetCDF file as longitude degrees east are common, I think it is how QGIS is mapping it that may be the problem, like it doesn't know how to convert the longitude degrees east.

The NetCDF has a single variable (Chlorophyll), with 4 dimensions (time, altitude, longitude and latitude). I downloaded it from https://coastwatch.pfeg.noaa.gov/erddap/griddap/erdMBchla1day.html using this bounding box: lat degrees north: 48, 55, lon degrees east: 227, 234

Also, I have tried mapping it in ArcGIS Pro, using the NetCDF to raster tool, and it works perfectly. Unfortunately, I need to be able to use it in QGIS as my ArcGIS Pro trial is about to expire.

I thought perhaps subtracting the longitude from 360 would solve the problem, so I used xarray to do so. QGIS crashed on trying to import this modified NetCDF so I assume that was not a good solution.

Any advice?


This nc file does not store its CRS in itself. So I used OSGeo4W Shell with this command;

gdal_translate -a_srs EPSG:4326 -of netCDF erdMBchla1day_8453_6188_94d0.nc erdMBchla1day_8453_6188_94d0_4326.nc

enter image description here

  • Thank you so much Kazuhito. I ran the code you gave me in the OSGeo4W Shell command window (I had to run as administrator or permission was denied) and it created an output NetCDF that QGIS mapped in the correct location :) However, OSGeo4W also produced a warning when running the code: "Warning 1: Recode from UTF-8 to CP_ACP failed with the error: "Invalid argument".Input file size is 281, 281." I'm not sure what it means or if it matters, the NetCDF seems okay. It isn't a problem as such but if you have any thoughts on it I love to know. – Orla Osborne Nov 20 '20 at 23:22
  • @OrlaOsborne Sorry for this late reply. I do see the warning message in my OSGeo4W shell, but I honestly have not paid much attention to it. Perhaps the warning is coming from that NetCDF names of variables are encoded in UTF-8, but the Windows Command Shell is commonly ANSI encoded (S-JIS in my case). As far as the actual variable name is written in ASCII characters (e.g. chlor-a), the process itself would work without problems. But we still get warnings anyway. – Kazuhito Nov 23 '20 at 8:01
  • Ah okay, thank you! – Orla Osborne Nov 24 '20 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.