# Interpolation of data on non-rectangular grid [duplicate]

I have a smooth data distribution on a 2D regular grid that is not a rectangular (it is a cross-section of a channel) and I need to find an Interpolating function f[x,y]. I have tried Interpolation[{{x1,y1},f1},{x2,y2},f2},...}] but it doesn't work. Does Interpolation work only on rectangular grid?

Thanks Giovanni

• Have you tried a search on this very site? May 29, 2013 at 13:16
• Or how about the Mathematica help? To give a short answer, Interpolation works not only on rectangular grids. May 29, 2013 at 13:24
• Please could you be more specific about the meaning of "doesn't work"? Also, see (20372). (This was suggested by the review panel as a possible duplicate. Clearly the question is not a duplicate so I skipped the review, but the answer is highly relevant. I am leaning toward closing this as TL unless clarification comes from the OP.) May 29, 2013 at 19:11

Interpolation does not only work on rectangular grids. The grid even need not to be regular.

E.g. let us produce some data (x, y,z) which are not on a regular grid on a disk with radius of 5 in the x-y plane and which have z-values between 4 and 5 with:

radius=5;
maxRandomNumber=1000;
Sqrt[RandomReal[{0,1},maxRandomNumber]],
2*Pi*RandomReal[{0,1},maxRandomNumber],RandomReal[{4,5},maxRandomNumber]];
data = Transpose[{x, y, z}];


If you plot them with

 ListPlot3D[data]


You get something like

You can interpolate the data easily with

f = Interpolation[data, InterpolationOrder -> 1];


Plotting them with

Plot3D[f[x, y], {x, -6, 6}, {y, -6, 6},
RegionFunction -> Function[{x, y}, Sqrt[x^2 + y^2] < radius]]


Or

ContourPlot[f[x, y], {x, -6, 6}, {y, -6, 6},
RegionFunction -> Function[{x, y}, Sqrt[x^2 + y^2] < radius]]


give you a similar picture as the first one. So you see, interpolation still works for such data.

• This does not work with dimensions greater than 4, e.g. data={{a,b,c,d,e}, ...} -> f[a,b,c,d]=e May 3, 2017 at 14:36