# 2D Interpolation on an irregular grid

I want to do 2D interpolation on an irregular grid.

In particular, I have a function f:\mathbb R^2 \rightarrow \mathbb R, (x, y) \mapsto z. I have an irregular grid D = (x_i, y_i)_i as well as the corresponding values F = (f_i)_i. I would like to interpolate D, F to obtain f.

I have tried Dierckx, which according to the documentation supports 2D interpolation on irregular grids, but keeps giving me the following error:
(quasi) coincide with an old one: s too small or too large a weight to
an inaccurate data point. The weighted least-squares spline
corresponds to the current set of knots.”

I am currently using the “NaturalNeighbours” package in Julia to do the interpolation, and I have also used “Kriging”, but both are extremely slow.

I would love to hear any suggestions on how to speed up the performance of the interpolation, as well as if there are ways to fix the error I am getting with Dierckx.

Thanks!

Have you tried Interpolations.jl.
This is a link to the irregular grid interpolation feature:
https://juliamath.github.io/Interpolations.jl/latest/control/#Gridded-interpolation

In any case, giving more info about the irregular grid (how big, dense, regular it is? How many dimensions?) would help.

It sounds like the OP needs scattered interpolation of some kind so perhaps ScatteredInterpolation.jl will work.

https://eljungsk.github.io/ScatteredInterpolation.jl/dev/

The idea is that you’re going to use some kind of radial basis function convolved with the points that you have sampled to intepolate over the remaining continuous space.

You can also try GitHub - gher-uliege/DIVAnd.jl: DIVAnd performs an n-dimensional variational analysis of arbitrarily located observations, which allows smoother interpolation from scattered points, where multiple data at the same position can be dealt with.

1 Like

One more suggestion: try GMT.jl’s splines in tension and see a simple example here.

1 Like

Another suggestion is the pure Julia version of the Clough-Tocher 2d interpolation that I ported from scipy:

3 Likes

And if one wants the choice of the full pack of GMT + GDAL interpolation methods see gridit

1 Like

Another native Julia option:

Check this textbook, chapter 11:

https://juliaearth.github.io/geospatial-data-science-with-julia/

1 Like

I am currently using the “NaturalNeighbours” package in Julia to do the interpolation, and I have also used “Kriging”, but both are extremely slow.

Just curious: What was slow for NaturalNeighbours.jl? Are you computing it in batches? What method are you using? It should be very performant, so I’m interested in improving it. If you give some example data and how you are calling it I can look into it also.

2 Likes