# Interpolation/Kriging

**URL:** https://discourse.paraview.org/t/interpolation-kriging/8273
**Category:** ParaView Support
**Created:** [October 27, 2021, 7:56pm UTC](https://discourse.paraview.org/t/interpolation-kriging/8273 "2021-10-27T19:56:13Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Victor\_Saouma](https://discourse.paraview.org/user_avatar/discourse.paraview.org/victor_saouma/32/4946_2.png) [@Victor\_Saouma](https://discourse.paraview.org/u/Victor_Saouma)
#### Post date: [October 27, 2021, 7:56pm UTC](https://discourse.paraview.org/t/interpolation-kriging/8273/1 "2021-10-27T19:56:13Z")

</div>

I have a complex unstructured mesh that I would like to shade with field measurements. However, those are at only select locations. They can be assigned to nodes or elements.  
Question: Is there a Paraview tool to interpolate in between, preferably using Krieging?

---

<div class="post-metadata">

### Author: ![Kenichiro-Yoshimi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Kenichiro-Yoshimi](https://discourse.paraview.org/u/Kenichiro-Yoshimi)
#### Post date: [October 28, 2021, 2:29am UTC](https://discourse.paraview.org/t/interpolation-kriging/8273/2 "2021-10-28T02:29:01Z")

</div>

An external Kriging python library can be applied using the **Programmable Filter**.

For example, if you want to use PyKrige ([PyKrige — PyKrige 1.6.1 documentation](https://geostat-framework.readthedocs.io/projects/pykrige/en/stable/)), first, prepare the same version of the Python environment that ParaView uses, and install Pykrige on it. Then, copy:

- Anaconda3/envs/pyKrige/Lib/site-packages/pykrige

- Anaconda3/envs/pyKrige/Lib/site-packages/scipy  
(This is an Anaconda example)

under _(ParaView install folder)/bin/Lib/site-packages_. After this preparation, start ParaView and apply a programmable filter to your geometry and observation points. Below is a concrete sample and its State file.

 ![kriging_sample](https://discourse.paraview.org/uploads/default/original/2X/a/aa8be8ee93cd48786eb25105729b49061de39f4a.png)

[pyKrige.pvsm](https://discourse.paraview.org/uploads/short-url/imT9VFq3GRXc7bEKnO6yinjTqlF.pvsm) (567.3 KB)

The operation procedure is as follows.

1. Select the geometry data (UnstructuredCellTypes1) you want to interpolate or extrapolate in the Pipeline Browser.
2. Continue to select the observation point data (RandomAttributes1) while holding down the Ctrl key.
3. Then, start the **Programmable Filter**
4. Type in the following in **Script** :

```python
from pykrige.ok3d import OrdinaryKriging3D

grid = self.GetInputDataObject(0, 0)
pnts = inputs[1]
output.CopyStructure(grid)

k_psill = 10.0
k_range = 5.0
k_nugget = 0.002

ok3d = OrdinaryKriging3D(
    pnts.Points[:,0], pnts.Points[:,1], pnts.Points[:,2], pnts.PointData['RandomPointScalars'],
    variogram_model="gaussian", variogram_parameters ={'psill': k_psill, 'range': k_range, 'nugget': k_nugget}
    #anisotropy_scaling_y=None, anisotropy_angle_z=None
)

k3d1, ss3d = ok3d.execute('points', output.Points[:,0], output.Points[:,1], output.Points[:,2])

output.PointData.append(k3d1, 'kriging')

```

---

<div class="post-metadata">

### Author: ![Victor\_Saouma](https://discourse.paraview.org/user_avatar/discourse.paraview.org/victor_saouma/32/4946_2.png) [@Victor\_Saouma](https://discourse.paraview.org/u/Victor_Saouma)
#### Post date: [October 28, 2021, 4:57am UTC](https://discourse.paraview.org/t/interpolation-kriging/8273/3 "2021-10-28T04:57:14Z")

</div>

Thanks, you have a nice simple square block for an example. In my case, my geometry is pretty complex,

 ![mc-1](https://discourse.paraview.org/uploads/default/original/2X/4/41a8bc3bbc86d2e864b5be8243654406512134ce.png)  
Still doable?

---

<div class="post-metadata">

### Author: ![Kenichiro-Yoshimi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Kenichiro-Yoshimi](https://discourse.paraview.org/u/Kenichiro-Yoshimi)
#### Post date: [October 28, 2021, 5:45am UTC](https://discourse.paraview.org/t/interpolation-kriging/8273/4 "2021-10-28T05:45:06Z")

</div>

Yes, it is possible. This method is not affected by the complexity of the geometry.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [October 28, 2021, 6:28am UTC](https://discourse.paraview.org/t/interpolation-kriging/8273/5 "2021-10-28T06:28:56Z")

</div>

FYI @Francois_Mazen

---

<div class="post-metadata">

### Author: ![Victor\_Saouma](https://discourse.paraview.org/user_avatar/discourse.paraview.org/victor_saouma/32/4946_2.png) [@Victor\_Saouma](https://discourse.paraview.org/u/Victor_Saouma)
#### Post date: [October 28, 2021, 3:28pm UTC](https://discourse.paraview.org/t/interpolation-kriging/8273/6 "2021-10-28T15:28:04Z")

</div>

Unfortunately, I have only used paraview with Matlab generated vtks.  
Would there be anyone in this forum who can implement for me Kyoshimi’s solution on a consultant basis?

---

<div class="post-metadata">

### Author: ![AE3X](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ae3x/32/7735_2.png) [@AE3X](https://discourse.paraview.org/u/AE3X)
#### Post date: [October 28, 2021, 3:36pm UTC](https://discourse.paraview.org/t/interpolation-kriging/8273/7 "2021-10-28T15:36:32Z")

</div>

This is a very detailed answer. Thank you very much for sharing that!

---

<div class="post-metadata">

### Author: ![Francois\_Mazen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/francois_mazen/32/6483_2.png) [@Francois\_Mazen](https://discourse.paraview.org/u/Francois_Mazen)
#### Post date: [October 29, 2021, 7:50am UTC](https://discourse.paraview.org/t/interpolation-kriging/8273/8 "2021-10-29T07:50:48Z")

</div>

Hello Victor,

Kitware can help you via paid services. You can reach out Kitware for consultancy using this page:  
[https://www.kitware.com/contact-us/](https://www.kitware.com/contact-us/)

Best,
