Scattered interpolation

Hi,

I am kind of struggling with scattered interpolation in Julia for 2D. What I have is a bunch of points (x,y,w), where x and y are coordinates and w is the value. I want to interpolate onto a regular grid. Currently for me this can be achieved by calling Python using linear interpolation:

using PyPlot
n = 100
X, Y, W = rand(n), rand(n), rand(n)
interval = 0.02
xi = range(minimum(X), stop=maximum(X), step=interval)
yi = range(minimum(Y), stop=maximum(Y), step=interval)
# Perform linear interpolation of the data (x,y) on grid(xi,yi)
triang = matplotlib.tri.Triangulation(X,Y)
interpolator = matplotlib.tri.LinearTriInterpolator(triang, W)
Xi = [y for x in xi, y in yi]
Yi = [x for x in xi, y in yi]
wi = interpolator(Xi, Yi)

Similar things can be done in MATLAB with scatteredInterpolant method.
I tried to look at the interpolation packages in Julia, but nothing works so far. Is there a native Julia way of doing this?

Thanks!

1 Like

GitHub - eljungsk/ScatteredInterpolation.jl: Interpolation of scattered data ?

3 Likes

Please take a look at GeoStats.jl, it has multiple solvers that you can use for spatial interpolation. There are many other packages that you can use for interpolation in Julia, including Interpolations.jl. Your choice depends on your goals.

1 Like

I did look at this package, but unfortunately, currently it does not support simple linear interpolation, and with large number of points memory becomes an issue.

I know there’s the Interpolations.jl package, but my impression is that mostly it contains gridded interpolation schemes but not scattered interpolations. I haven’t looked at the GeoStats.jl package. Will try later. Thanks!

GMT.jl has several interpolation algorithms

julia> G = surface(rand(1000,3) * 100, limits=(0,100,0,100), inc=0.5);
julia> imshow(G,title="Minimum curvature",colorbar=true,fmt=:png)

or a linear Delaunay triangulation

julia> G = triangulate(rand(1000,3) * 100, limits=(0,100,0,100), inc=0.5, grid=true);
 imshow(G,title="Delaunay Triangulation",colorbar=true,fmt=:png)

2 Likes