Tristian
Tristian

Reputation: 81

QGIS: latitude coordinates are reversed; map upside down

I have been using QGIS to display a map of the long term precipitation average of the Netherlands. However, when QGIS opens the data, the map is shown upside down

enter image description here

I noticed that the coordinates are displayed from 0 - 266 (lon) and -315 - 0 (lat). I figured that the latitude is projected upside down

enter image description here

In stead of -315 - 0 it should be 0 - 315 and the map should look fine. But I can't figure out how to inverse this value. The file is a NetCdf file. I openend the XML metadata QGIS made for me with EmEditor, but it did show the right coordinates (in lat/lon), So I think it has something to do with the way QGIS sets up the map or the way it converses the lat/lon to meters. Anybody who encountered the same problem as me? Thank you in advance!

Upvotes: 0

Views: 7670

Answers (3)

Majid Hojati
Majid Hojati

Reputation: 1790

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")

Upvotes: 1

Tristian
Tristian

Reputation: 81

Thanks to Micha (see the comments):

I was told to solve the problem using GDAL (Geospatial Data Abstraction Library), a method to look into and translate/process metadata. This was quitte hard to understand, while I am relatively new in programming and using powerfull 'languages' like GDAL. To enter GDAL codes I used the OSGeo4W Shell, which comes with QGIS. The command that I used to flip my map was:

gdal_translate -of netCDF -co WRITE_BOTTOMUP=NO my netcdf.nc output.nc

(see also this short GDAL/netCDF introduction).

Upvotes: 2

Micha
Micha

Reputation: 503

I'm pretty sure you can use the GDAL configuration option GDAL_NETCDF_BOTTOMUP=[YES/NO] to convert from NetCDF to a geotiff, and get the resulting raster correctly oriented north-up. Try using gdal_translate with the above option. See here for some more details.

Upvotes: 1

Related Questions