I have this raster (less than 10 mb). It is a historical simulation model (SMHI) created by CMIP5 clipped for the city of Amsterdam.
dropbox <- here is the file
What I want to do is to convert this rotated lat/lon to a WGS projection and then re-write the newly obtained raster using ncdf4 or Raster package in R (preferably ncdf4 since I have to do this with many files)
How to do this exactly?
I was trying something like for a single layer:
library(ncdf4) library(raster) library(rgdal) rs <- brick("SMHI_MPI-M-MPI-ESM-LR_historical_r1i1p1_RCA4_amsterdam_1970_2005.nc", varname = 'pr') rp <- rasterToPoints(rs[]) rp[,3] <- rp[,3] * 86400 # the precipitation is measured in kg m's (convert here to daily mm) # change the proj r2 <-project(rp[,1:2], paste("+proj=ob_tran +o_proj=longlat", "+o_lon_p=-162 +o_lat_p=39.25 +lon_0=180 +ellps=sphere +no_defs"), inv=TRUE, use_ob_tran=TRUE) # add the projected coordinates to the matrix; convert it to df rp[,1:2] <-r2 rp <-as.data.frame(rp) # convert it to spatial coordinates(rp)<-~x+y # plot it spplot(rp, scales = list(draw = T))