0

I have a netcdf file named "precip.mon.mean.nc" downloaded from https://www.esrl.noaa.gov/psd/data/gridded/data.cmap.html. It is a monthly mean precipitation dataset and the resolution is 2.5x2.5.

I wonder how I can regrid the precipitation data into 1x1 and 3x3 resolution respectively using interpolation method such as Kriging or inverse distance weighted (IDW). Thanks for the help.

require(ncdf4)

Precipitation = nc_open(filename = "precip.mon.mean.nc")
Pre=ncvar_get(Precipitation,varid = "precip")
Pre[Pre=-9.96920996838687e+36]=NA
lon=ncvar_get(Precipitation,varid = "lon")
aa=which(lon==181.25)
lon[aa:length(lon)]=lon[aa:length(lon)]-360
lat=ncvar_get(Precipitation,varid = "lat")
Date=ncvar_get(Precipitation,varid = "time")
nc_close(Precipitation)
Time=as.Date(Date/24,origin="1800-01-01")
Yang Yang
  • 858
  • 3
  • 26
  • 49
  • 1
    Have a look at my answer here: http://stackoverflow.com/questions/43006045/obtain-function-from-akimainterp-matrix/43064436#43064436 You can also directly use `raster::aggregate` and `raster::disaggregate` – Sébastien Rochette Apr 10 '17 at 15:07
  • 1
    @StatnMap Thank you so much for your reply, but I am still a bit confused, I wonder if you could give me an example using the data in my post? Thank you for your time. – Yang Yang Apr 10 '17 at 15:53

1 Answers1

1

For general interpolation solutions using R, check out this post.

In addition, I haven't used it myself, but the package idpw seems to have an option for inverse distance weighting.In addition this post and this page might help.

However, if you a very simple one liner, you can can do inverse distance weighting remapping of netcdf files by simply calling CDO with a system command. The option you need is remapdis, if the file is global you can simply specify the resolution using the regular grid specifier, for example with a 1x1 degree grid:

cdo remapdist,r360x180 precip.mon.mean.nc regridded.nc

as I say, you can call this from R using the system function. For further information on regridding methods and potential pitfalls see my online youtube video guide.

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86