[R] 2/3d interpolation from a regular grid to another regular grid

jiho jo.irisson at gmail.com
Tue Dec 4 16:55:40 CET 2007


Hello R users,

I have numerical data sampled on two grids, each one shifted by 0.5  
from the other.

For example:

grid1 = expand.grid(x=0:3, y=0.5:2.5)
grid2 = expand.grid(x=0.5:2.5, y=0:3)
gridFinal = expand.grid(x=0.5:2.5, y=0.5:2.5)

plot(gridFinal, xlim=c(0,3), ylim=c(0,3), col="black", pch=19)
points(grid1, xlim=c(0,3), ylim=c(0,3), col="red", pch=19)
points(grid2, xlim=c(0,3), ylim=c(0,3), col="blue", pch=19)

I would like to interpolate the quantities on grid1 (red) and grid2  
(blue) on the same grid (black). This scenario is very common in  
geophysical data and models. I only found:
- functions in package akima which are designed for irregular grids
- krigging in package fields, which also requires irregular spaced data
- approx or spline which works in 1D and which I could apply line by  
line and column by column and use a mean of both estimates
I am sure there are plenty of functions already available to do this  
but searching R-help and the packages site did not help. Pointer to a  
function/package would be highly appreciated.

Eventually, the same scenario will occur in 3D so if the function is  
3D capable it would be a plus (but I am sure the solution to this is  
generic enough to work in nD)

Thank you in advance.

JiHO
---
http://jo.irisson.free.fr/



More information about the R-help mailing list