jiho
2007-Dec-04 15:55 UTC
[R] 2/3d interpolation from a regular grid to another regular grid
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/
Scionforbai
2007-Dec-04 20:38 UTC
[R] 2/3d interpolation from a regular grid to another regular grid
> - krigging in package fields, which also requires irregular spaced dataThat kriging requires irregularly spaced data sounds new to me ;) It cannot be, you misread something (I feel free to say that even if I never used that package). It can be tricky doing kriging, though, if you're not comfortable with a little bit of geostatistics. You have to infer a variogram model for each data set; you possibly run into non-stationarity or anisotropy, which are indeed very well treated (maybe at best) by kriging in one of its forms, but ... it takes more than this list to help you then; basically kriging requires modelling, so it is often very difficult to set up an automatic procedure. I can reccomend kriging if the spatial variability of your data (compared to grid refinement) is quite important. In other simple cases, a wheighted mean using the (squared) inverse of the distance as wheight and a spherical neighbourhood could be the simpliest way to perform the interpolation.