1

I'm trying to import NetCDF layers with environmental information to QGIS and they appear flipped and rotated

In the top-left you can see the Europe coastal line I was using, in the bottom-right the nc layer screencap upside-down and rotated

When importing them to a friend's ArcGis I can choose which subdataset I want to use as X and Y coordinates, there are four candidates: lat, lon, nlat and nlon. After some trials and errors I finally got it right in ArcGis, but in QGIS importing it (Layer > Add layer > Add raster layer) there isn't any option to choose the coordinates.

After doing some research I found in a another post here a way of fixing the y-axis with GDAL in OSGeo4W

    gdal_translate -of netCDF -co WRITE_BOTTOMUP=NO NETCDF:"filename.nc":datasetname newfile.nc

For example:

gdal_translate -of netCDF -co WRITE_BOTTOMUP=NO NETCDF:"ATS_LST_3PUUOL200208XX_0.50X0.50_CS3_LSM.nc":LST 200208_05_LST.nc

Althought I got some warnings:

Warning 1: dimension #2 (nlat) is not a Longitude/X dimension.
Warning 1: dimension #1 (nlon) is not a Latitude/Y dimension.
Warning 1: dimension #0 (diurnal) is not a Time or Vertical dimension.
Input file size is 360, 720
0...10Warning 1: dimension #2 (nlat) is not a Longitude/X dimension.
Warning 1: dimension #1 (nlon) is not a Latitude/Y dimension.
Warning 1: dimension #0 (diurnal) is not a Time or Vertical dimension.
Warning 1: dimension #2 (nlat) is not a Longitude/X dimension.
Warning 1: dimension #1 (nlon) is not a Latitude/Y dimension.
Warning 1: dimension #0 (diurnal) is not a Time or Vertical dimension.
Warning 1: creating geographic file without lon/lat values!

Now the y-axis seems fine

screencap rotated 90°

Is there a way to do this for the x-axis? I found nothing here

This layer in specific is called ATS_LST_3PUUOL200208XX_0.50X0.50_CS3_LSM from CEDA

Here are the files in my dropbox if you don't have access to the webpage

  • 2
    flip the lat and lon round - it's twisted through 90 degrees – Ian Turton Feb 21 '18 at 15:07
  • Thanks for answering that fast. Yes it appears inverted and twisted. How do I fix it? – Moskar Feb 21 '18 at 15:34
  • depends on how you imported it – Ian Turton Feb 21 '18 at 15:35
  • Just adding it from the browser panel, I'm going to try other methods to see if I can see an option for doing that – Moskar Feb 21 '18 at 15:38
  • Well, I don't see how to do that. The only choices while adding the layer are to select the data to import and the CRS. The file is a netCDF (.nc) – Moskar Feb 21 '18 at 15:52
0

In R you can use rotate function



library(raster)
library(gdalUtils)


workdir <- "Your workind dir"
setwd(workdir)

ncfname <- "adaptor.mars.internal-1563580591.3629887-31353-13-1b665d79-17ad-44a4-90ec-12c7e371994d.nc"

# get the variables you want
dname <- c("v10","u10") 


# open using raster 
datasetName <-dname[1]
r <- raster(ncfname,  varname = datasetName)
r2 <- rotate(r)

writeRaster(r2,"wind.tif",driver = "TIFF")

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.