6

I have netCDF files downloaded from here. They are at 0.5*0.5 resolution. I want to re-grid these files at a coarser resolution of 1*1. I found some links. First link talks about re-grid in R, but without using bi-linear interpolation. The second link deals with bi-linear interpolation, but using climate data operator (to which I am not very much familiar). Then I came across an R package HiClimR. In this package, a command coarseR reduces the resolution of data. I converted netCDF file into an excel file and used coarseR. But after getting results I found that this command actually skipped longitude latitude in some way and reduced the resolution to 1*1. In nut shell, my problems are

(1) Is it right to use coarseRfor reducing resolution? (2) How can bi-linear transformation be used for my specific problem in R?

Many thanks in advance.

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
Pankaj
  • 1,296
  • 2
  • 13
  • 23

1 Answers1

7

CDO has some very nice regridding functions built in that you can now access directly from within R using the package climate operators. After installation with

devtools::install_github("markpayneatwork/ClimateOperators")

you load it with

library(ClimateOperators)

For example to regrid to 1x1 regular grid using bilinear interpolation as you ask, from a linux command line you would simply do:

cdo remapbil,r720x360 in.nc out.nc

Which using the climate operators package in R, would translate to

cdo("remapbil,r720x360","in.nc","out.nc") 

(you can see how the command is built up without running it using the option "debug=True" in the call).

However, if you are converting to a coarser grid then it may be advisable to use a conservative remapping technique, otherwise you can miss points out during the remapping. This is especially important for highly heterogeneous fields such as precipitation. In this case, CDO offers both first and second order conservative remapping techniques. To use the first order technique

cdo remapcon,r720x360 in.nc out.nc

(Note that occasionally you may find CDO throwing a wobbly due to loss of precision during the conversion if the data is "packed" and in this case it will suggest you use the option "-b f32" or "-b f64".)

Common regridding options to consider are:

  • remapbil: Bilinear interpolation
  • remapnn: Nearest neighbour interpolation (i.e. takes value from closest cell)
  • remapcon: First order conservative remapping
  • remapcon2: Second order conservative remapping

An explanation on regridding technique and how to implement them with CDO is given in more detail in my youtube video guide on climate unboxed.

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
  • I am not familiar with CDO, but I will try. Thanks for your answer. – Pankaj Jan 17 '18 at 11:55
  • If you are on a Ubuntu machine you can install it simply with sudo apt-get install cdo. On a MAC it is straightforward as well. If you are on windows there is a CDO binary but I have never tried it, I think they recommend installing in on the cygwin environment. – ClimateUnboxed Jan 17 '18 at 13:05
  • Update to my comment above, on windows 10 it is now simple to install linux ubuntu as a subsystem, and then you can simply type sudo apt-get install cdo as per pure linux. – ClimateUnboxed Jan 15 '20 at 13:28
  • 1
    If you use Python, you can get it with conda. Use `conda install cdo` and you will get it installed on your venv. Now you can use it from terminal: `cdo ...`. – Xbel Aug 05 '21 at 08:21
  • in 2019 a new oackage was launched which makes the use of cdo from R much easier, see my revised answer – ClimateUnboxed Oct 09 '21 at 17:32