# Interpolating z-values from a Delaunay2D mesh

**URL:** https://discourse.vtk.org/t/interpolating-z-values-from-a-delaunay2d-mesh/9047
**Category:** Support
**Tags:** python
**Created:** [July 31, 2022, 12:37am UTC](https://discourse.vtk.org/t/interpolating-z-values-from-a-delaunay2d-mesh/9047 "2022-07-31T00:37:18Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![llobera](https://discourse.vtk.org/user_avatar/discourse.vtk.org/llobera/32/5540_2.png) [@llobera](https://discourse.vtk.org/u/llobera)
#### Post date: [July 31, 2022, 12:37am UTC](https://discourse.vtk.org/t/interpolating-z-values-from-a-delaunay2d-mesh/9047/1 "2022-07-31T00:37:19Z")

</div>

I used VtkDelaunay2D to generate a mesh (vtkPolyData?) from a set of points. I am now looking for a way to be able to interpolate z values (in my case these correspond to elevations) from a set of xs and ys. What would be the most optimal way of doing this?

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [July 31, 2022, 10:18am UTC](https://discourse.vtk.org/t/interpolating-z-values-from-a-delaunay2d-mesh/9047/2 "2022-07-31T10:18:47Z")

</div>

It sort of depends on how the ps=(xs,ys) values are produced. Do you know which triangles the ps are in? This can save some work as you can simply interpolate from the triangle’s points. Another approach, you can perform a vertical ray cast (in the +/- z direction) to determine the point (use a static cell locator or equivalent). Finally, and this is likely the fastest, there are rendering tricks that can be used (render/color based on elevation, or obtain z-buffer values etc.). The particulars of the application will likely dictate which approach you use.

---

<div class="post-metadata">

### Author: ![llobera](https://discourse.vtk.org/user_avatar/discourse.vtk.org/llobera/32/5540_2.png) [@llobera](https://discourse.vtk.org/u/llobera)
#### Post date: [August 1, 2022, 12:23am UTC](https://discourse.vtk.org/t/interpolating-z-values-from-a-delaunay2d-mesh/9047/3 "2022-08-01T00:23:59Z")

</div>

Thank you for your reply!  
No, I do not know the triangles on which the ps are. The ps are arbitrary points withing the x and y ranges defining the delaunay2d triangulation.

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [August 1, 2022, 9:32am UTC](https://discourse.vtk.org/t/interpolating-z-values-from-a-delaunay2d-mesh/9047/4 "2022-08-01T09:32:13Z")

</div>

Not sure if this will help but checkout [VTK Classes used in the Examples](https://kitware.github.io/vtk-examples/site/Cxx/Coverage/CxxVTKClassesUsed/) and search for ` vtkDelaunay2D`.

---

<div class="post-metadata">

### Author: ![Christos\_Tsolakis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/christos_tsolakis/32/2076_2.png) [@Christos\_Tsolakis](https://discourse.vtk.org/u/Christos_Tsolakis)
#### Post date: [August 1, 2022, 12:22pm UTC](https://discourse.vtk.org/t/interpolating-z-values-from-a-delaunay2d-mesh/9047/5 "2022-08-01T12:22:17Z")

</div>

> Not sure if this will help but checkout [VTK Classes used in the Examples](https://kitware.github.io/vtk-examples/site/Cxx/Coverage/CxxVTKClassesUsed/) and search for `vtkDelaunay2D` .

In particular, I would suggest looking into [https://kitware.github.io/vtk-examples/site/Cxx/PolyData/InterpolateMeshOnGrid/](https://kitware.github.io/vtk-examples/site/Cxx/PolyData/InterpolateMeshOnGrid/)

---

<div class="post-metadata">

### Author: ![llobera](https://discourse.vtk.org/user_avatar/discourse.vtk.org/llobera/32/5540_2.png) [@llobera](https://discourse.vtk.org/u/llobera)
#### Post date: [August 2, 2022, 2:21am UTC](https://discourse.vtk.org/t/interpolating-z-values-from-a-delaunay2d-mesh/9047/6 "2022-08-02T02:21:14Z")

</div>

Will do! Thanks for the suggestion!
