[SciPy-Dev] Bivariate interpolation and NaN
Charles R Harris
Fri Jun 10 02:14:59 CDT 2011
On Fri, Jun 10, 2011 at 1:01 AM, Charles R Harris <email@example.com
> On Fri, Jun 10, 2011 at 12:26 AM, Ole Nielsen <
> firstname.lastname@example.org> wrote:
>> Dear Scipy developers
>> I am working on a project where we need to interpolate from gridded data
>> to individual points.
>> We want it to be fast, bilinear (i.e. smooting is not important) and be
>> able to deal with NaN in a sensible way.
>> I looked at a few and settled for RectBivariateSpline which is part of
>> It works well but, we have encountered two problems:
>> 1. If there is a single NaN in the grid, all interpolated points
>> become NaN even if the surrounding pixels are valid floating point numbers.
>> I would have expected NaNs only for points whose immediate neighbours
>> contain NaN.
>> 2. We have noticed small 'overshoots', i.e. interpolated values may be
>> outside the range of the gridded data. Can anyone tell me if this is
>> I think both are expected. Splines are a global fit and nans will cause
> global trouble. Likewise, splines can exhibit ringing. You can use a
> smoothing spline to get around that, but it won't interpolate the data
> points exactly. It sounds to me like you want something local, for instance
> bi-cubic interpolation or bilinear (the algorithm name). There are some
> tools for this sort of thing in scipy.ndimage, and tools like gdal or
> imagemagick might also do what you want depending on the specifics of the
I should say that I interpreted gridded as evenly spaced points on a square
grid. If that is not the case the LinearNDInterpolator might be your best
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-Dev