Gregory Jefferis
2006-Mar-14 18:13 UTC
[R] Interpolate univariate data on regular 3D grid to new 3D grid
Dear R Users, I have some data that is very similar in form to a 3D image - ie univariate data on a regular 3D grid. I keep this as a 3D numeric array in R with attributes describing the sampling points along the 3 dimensions. I would like to interpolate this onto a new regular 3D grid that I specify (eg by supplying 3 vectors corresponding to the new grid locations on each of the 3 dimensions). Interpolation methods would ideally include nearest neighbour and linear. The arrays can be large (> 1e7 points) so I would like this to be efficient. I can find lots of 1d or 2d interpolation methods but no 3d ones and anything that I write will probably take me a while to optimise. Many thanks for any suggestions, Greg Jefferis. -- Gregory Jefferis, PhD and: Research Fellow Department of Zoology St John's College University of Cambridge Cambridge Downing Street CB2 1TP Cambridge, CB2 3EJ United Kingdom Lab Tel: +44 (0)1223 336683 Office: +44 (0)1223 339899 Lab Fax: +44 (0)1223 336676 http://www.zoo.cam.ac.uk/zoostaff/jefferis.html gsxej2 at cam.ac.uk
Edzer J. Pebesma
2006-Mar-14 20:00 UTC
[R] Interpolate univariate data on regular 3D grid to new 3D grid
Package gstat allows 3D interpolation. It doesn't accept a 3D array directly; you'll have to provide it as x1 y1 z1 obs1 x2 y2 z2 obs2 etc, e.g. by using expand.grid. Or, you may want to try out the classes provided by package sp, which allow for more than 2 dimensions in case of points and grids. -- Edzer