# Scattered interpolation

**URL:** https://discourse.julialang.org/t/scattered-interpolation/31733
**Category:** General Usage
**Tags:** interpolations
**Created:** [December 2, 2019, 4:55am UTC](https://discourse.julialang.org/t/scattered-interpolation/31733 "2019-12-02T04:55:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![henry2004y](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henry2004y/32/9284_2.png) [@henry2004y](https://discourse.julialang.org/u/henry2004y)
#### Post date: [December 2, 2019, 4:55am UTC](https://discourse.julialang.org/t/scattered-interpolation/31733/1 "2019-12-02T04:55:05Z")

</div>

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:

```julia
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!

---

<div class="post-metadata">

### Author: ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)
#### Post date: [December 2, 2019, 9:15pm UTC](https://discourse.julialang.org/t/scattered-interpolation/31733/2 "2019-12-02T21:15:42Z")

</div>

[GitHub - eljungsk/ScatteredInterpolation.jl: Interpolation of scattered data](https://github.com/eljungsk/ScatteredInterpolation.jl) ?

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [December 2, 2019, 10:25pm UTC](https://discourse.julialang.org/t/scattered-interpolation/31733/3 "2019-12-02T22:25:57Z")

</div>

Please take a look at [GeoStats.jl](https://github.com/juliohm/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](https://github.com/JuliaMath/Interpolations.jl). Your choice depends on your goals.

---

<div class="post-metadata">

### Author: ![henry2004y](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henry2004y/32/9284_2.png) [@henry2004y](https://discourse.julialang.org/u/henry2004y)
#### Post date: [December 2, 2019, 11:07pm UTC](https://discourse.julialang.org/t/scattered-interpolation/31733/4 "2019-12-02T23:07:00Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![henry2004y](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henry2004y/32/9284_2.png) [@henry2004y](https://discourse.julialang.org/u/henry2004y)
#### Post date: [December 2, 2019, 11:15pm UTC](https://discourse.julialang.org/t/scattered-interpolation/31733/5 "2019-12-02T23:15:24Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [December 3, 2019, 1:37am UTC](https://discourse.julialang.org/t/scattered-interpolation/31733/6 "2019-12-03T01:37:54Z")

</div>

[GMT.jl](https://www.generic-mapping-tools.org/GMT.jl) has several interpolation algorithms

```julia
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
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)

```

 ![MinCurv](https://global.discourse-cdn.com/julialang/original/3X/2/0/201751db21c082abfbaf839d4ee71b85fdbfcb1f.png)

 ![Delaun](https://global.discourse-cdn.com/julialang/original/3X/a/c/ac9e099501c444551f1f8ad11f0635b640fdf4fb.png)
