My question is about using R to transform raster data from a rotated pole projection to a regular latlon grid - and then plotting it.
I am working with data from a numerical weather model, which is specified in a rotated latlon grid - I do this entirely in R. The data is provided in grib format, which is easily read with "raster" package. As example data, I have a grib file in a format identical to the weather data but with ground elevation values for my area of interest (Denmark and southern Sweden) - (example data available here).
Loading and plotting the data looks like:
library("raster") geopotential <- raster(dk_geopotential_file) plot(geopotential, xlab="Longtitude (rotated)",ylab="Lattitude (rotated)")
This looks good - shapes of Denmark and Sweden is clearly seen. Asking for the crs information (as a proj4 string) of the rotated grid gives:
> crs(geopotential) CRS arguments: +proj=longlat +a=6367470 +b=6367470 +no_defs
Now I want to transform this into a regular WGS84 lat-lon format of the type:
"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
I would normally do this with the projectRaster function:
geopotential_wgs84 <- projectRaster(geopotential, crs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ")
Choosing CRS / PROJ4 string for EURO-Cordex rotated pole projection? seems to do this for a shapefile with the sf package, but I can't make it work with my raster data.
In my case, the coordinates of the geographic South Pole (not the North Pole as in the two linked threads) in the rotated grid is: (lon;lat) = (3;-40).