# 3D interpolation in Julia

**URL:** <https://discourse.julialang.org/t/3d-interpolation-in-julia/117035>\
**Category:** Numerics\
**Tags:** package, interpolations\
**Created:** [July 14, 2024, 4:17pm UTC](https://discourse.julialang.org/t/3d-interpolation-in-julia/117035 "2024-07-14T16:17:47Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 19, 2024, 11:06pm UTC](https://discourse.julialang.org/t/3d-interpolation-in-julia/117035/20 "2024-07-19T23:06:25Z")

</div>

@JoshuaLampert, FYI, I tried your excellent package for interpolating the scattered points of the sin(x\*y) function as in the example [in this post](https://discourse.julialang.org/t/plot-3d-data-in-a-2d-contour-plot/71251/2), and got what appears to be excellent results for that type of input data:

 ![KernelInterpolation_of_sin_of_xy](https://global.discourse-cdn.com/julialang/original/3X/d/f/dfbcb168dbe77d50c66ceda6fc38f12d8709b10d.png)

> **KernelInterpolation code**
>
> ```julia
> using KernelInterpolation, Plots
> 
> # 1 - INPUT DATA:
> n = 200
> xs, ys = 2π*(rand(n) .- 0.5), 2π*(rand(n) .- 0.5)
> zs = 100*sin.(xs .* ys)
> 
> # 2 - KERNEL INTERPOLATION:
> nodes = NodeSet([xs ys])
> values = zs
> kernel = GaussKernel{dim(nodes)}(shape_parameter = 1.0)
> itp = KernelInterpolation.interpolate(nodes, values, kernel)
> N = 100
> nodeset = homogeneous_hypercube(N, (-π, -π), (π, π))
> itp_values = itp.(nodeset)
> 
> # 3 - PLOT RESULTS:
> x = unique(values_along_dim(nodeset, 1))
> y = unique(values_along_dim(nodeset, 2))
> heatmap(x, y, reshape(itp_values, (N,N))', ratio=1, lims=(-π,π))
> scatter!(xs, ys, marker_z = zs, ms=3, msw=0.5)
> 
> ```

---

_[View the full topic](https://discourse.julialang.org/t/3d-interpolation-in-julia/117035)._
