[Numpy-discussion] Vector interpolation on a 2D grid

Pauli Virtanen pav@iki...
Fri Nov 6 16:45:22 CST 2009


pe, 2009-11-06 kello 17:20 -0500, Pierre GM kirjoitti:
> All,
> I have a vector of observations (latitude,longitude,value) that I
need  
> to interpolate over a given area.
> So far, I used Jeff W's basemap to transform the lat/lon in
> arbitrary  x/y and construct a regular grid, Robert K's delaunay
> triangulation  
> routine to project the points on the grid and its nearest-neighbor  
> interpolator to get a 2D array of estimates.
> Have a look for yourself at http://grab.by/gY3
> Some colleagues complained that the result looked a bit too choppy,  
> meaning that too much weight was given to the actual observations.
> What are my other options ?

You could try to use linear interpolation from the delaynay package
(only supports slicing, so is a bit tricky to use). I may be slightly
smoother than the natural neighbour one.

For scattered data, when I wasn't happy with delaunay, I've also used
the radial basis functions (Rbf) from scipy.interpolate -- something
like

        interpolator = Rbf(x, y, z, function='thin-plate', smooth=1e-9)

should give an interpolator that is reasonably smooth between the data
points. (I'd guess you can give it leeway in trading interpolation to
smoothness by increasing the smooth parameter.) Other Rbf functions than
thin-plate splines might also work.

I don't think RBF have any monotonicity guarantees, though -- if you
have some data points much closer to each other than others, some
spurious swings may develop, especially if the closely packed points
have large gradients between them.

Perhaps another fallback could be SmoothBivariateSpline. But with it,
I've often had serious problems: with sparse data I tend to get very
nonmonotonic behavior between the data points.

-- 
Pauli Virtanen



More information about the NumPy-Discussion mailing list