# ResampleWithDataset and extrapolate to nearby points

**URL:** https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034
**Category:** ParaView Support
**Created:** [February 27, 2024, 1:35pm UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034 "2024-02-27T13:35:27Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![simonw](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@simonw](https://discourse.paraview.org/u/simonw)
#### Post date: [February 27, 2024, 1:35pm UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/1 "2024-02-27T13:35:27Z")

</div>

Dear all,

 ![grafik](https://discourse.paraview.org/uploads/default/original/2X/d/de655a054d790e46a465bf19ecc1304b727d248f.png)

This is the result of interpolating experimental data on a finite element mesh using **ResampleWithDataset** filter.  
The missing points along the circle have value zero (blue in the contour above) because these points were not measured or have NaN.  
However, the distance to the points living on the circle is small, so I want to **extrapolate** (nearest neighbor, bilinear, …) to have values everywhere.

Here is a state file containing the data and the output of the filter  
[state.pvsm](https://discourse.paraview.org/uploads/short-url/vP3hy1MDTyksM1PyimNqm83OKE0.pvsm) (551.5 KB)

Here are the data (points and experimental values):  
[nodes.csv](https://discourse.paraview.org/uploads/short-url/y08hkHYbGGvqlfYWC5ahDKAlHUT.csv) (7.4 KB)  
[data.txt](https://discourse.paraview.org/uploads/short-url/zxWHy3qtqojMTEp6LDAwfTApLZB.txt) (655.1 KB)

and the sequence of filters to generate the output  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/3/38969c21b9469c8426114b32dbab62963a3d137e.png)

Is there any filter in paraview / pvpython that enables extrapolation or anything else I can do in paraview?

Thank you!

---

<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: [February 27, 2024, 1:36pm UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/2 "2024-02-27T13:36:26Z")

</div>

please share your data

---

<div class="post-metadata">

### Author: ![simonw](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@simonw](https://discourse.paraview.org/u/simonw)
#### Post date: [February 27, 2024, 1:46pm UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/3 "2024-02-27T13:46:41Z")

</div>

@mwestphal I uploaded a state file in my question.

---

<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: [February 27, 2024, 1:48pm UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/4 "2024-02-27T13:48:56Z")

</div>

state file does not contains data Im afraid.

---

<div class="post-metadata">

### Author: ![simonw](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@simonw](https://discourse.paraview.org/u/simonw)
#### Post date: [February 27, 2024, 1:59pm UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/5 "2024-02-27T13:59:49Z")

</div>

@mwestphal I uploaded the data manually and a screenshot how I apply the filter. Does this help?

---

<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: [February 27, 2024, 2:11pm UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/6 "2024-02-27T14:11:44Z")

</div>

Use a calculator to replace the NaNs with zero:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/f/fa38fd9e676f6e31807b5b2030e82e180c55b623.jpeg)

[state.pvsm](https://discourse.paraview.org/uploads/short-url/ccb5yXk3tpwoPrxoQV0R1Bxnz64.pvsm) (719.2 KB)

---

<div class="post-metadata">

### Author: ![simonw](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@simonw](https://discourse.paraview.org/u/simonw)
#### Post date: [February 27, 2024, 2:24pm UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/7 "2024-02-27T14:24:46Z")

</div>

I can not open the state file  
**ERROR: In vtkDelimitedTextReader.cxx, line 648**

**vtkDelimitedTextReader (0x17245b30): caught exception: Unable to open input file /home/glow/data/tmp/u2\_325.txt**

What is the calculator essentially doing? At the end, the values at the circle are still zero and no extrapolation happened.

---

<div class="post-metadata">

### Author: ![simonw](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@simonw](https://discourse.paraview.org/u/simonw)
#### Post date: [February 27, 2024, 4:25pm UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/8 "2024-02-27T16:25:42Z")

</div>

@mwestphal My idea of extrapolation is not to replace the NaN’s by 0 but by a value related to the neighbor values, which are from 0.

Is that possible?

---

<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: [February 27, 2024, 4:34pm UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/9 "2024-02-27T16:34:16Z")

</div>

> [@simonw](#):
>
> caught exception: Unable to open input file /home/glow/data/tmp/u2\_325.txt

you obviously need to change the path to your own paths.

> At the end, the values at the circle are still zero and no extrapolation happened.

Indeed, you can just remove the NaN point and let delaunay do its thing.

Here is a new version, you still need to change the path when you load the state:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/3/328de1b979719fa66e41da554213df922ccc602b.jpeg)

[state.pvsm](https://discourse.paraview.org/uploads/short-url/dSwaDzmHvj86jwI99PcqTapvyrB.pvsm) (900.5 KB)

---

<div class="post-metadata">

### Author: ![simonw](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@simonw](https://discourse.paraview.org/u/simonw)
#### Post date: [February 28, 2024, 10:36am UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/11 "2024-02-28T10:36:40Z")

</div>

@mwestphal

I could reproduce the result in your state file. Basically, you have added an selection u\>=0 followed by another delaunay. The trick is that the selection u\>=0 gets rid of the NaN’s in my data, hence forcing the delaunay to triangulate the entire domain resulting in interpolation everywhere, even between the hole. Is it like that?

---

<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: [February 28, 2024, 10:42am UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/12 "2024-02-28T10:42:18Z")

</div>

> [@simonw](#):
>
> Is it like that?

Exactly

---

<div class="post-metadata">

### Author: ![Kenneth](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/94ad74/32.png) [@Kenneth](https://discourse.paraview.org/u/Kenneth)
#### Post date: [March 29, 2025, 2:01pm UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/13 "2025-03-29T14:01:14Z")

</div>

ResampleWithDataSet provides a pickable option “Snap data to Cell with Closest Data”. Without choosing this option, points outside of the domain get a zero which for fields that cannot be zero is bad so I was very hopeful to see this option become available. However, to me, Snap means to not extrapolate, rather to take the closest boundary value directly.  
Examining the data, it does seem to be extrapolating. According to the information tab which gives the Ranges → [min, max]  
Source  
[0.0008571940043974022, 0.15147366645850846]  
Target  
[-0.0017042262373027119, 0.15147364187106566]  
Note the source and target are generated from the same CAD so we are talking about roundoff error in the mesh generation that leaves a significant fraction of the points outside of the domain and critically lots of them on a wall surface with dramatic solution variation so this is really bad because the flow solver downstream will not accept 0 density as an starting field (equation of state blows up) and an extrapolated negative value is even worse.

I don’t see anyway for a target to give a negative value from a uniformly positive source field without doing extrapolation which to my understanding is not what snap means.

My hack around this, provides a “safe” but very inaccurate starting field by using transform to scale (shrink) and translate such that no points on the target mesh fall outside of the domain.

ScaleShift  
[0.000857194435906585, 0.15147185625300372]

Can we get an option that is truly Snap and a separate one for extrapolate (which in my case is catastrophically bad)?

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [July 7, 2025, 9:48am UTC](https://discourse.paraview.org/t/resamplewithdataset-and-extrapolate-to-nearby-points/14034/14 "2025-07-07T09:48:52Z")

</div>

> [@Kenneth](#):
>
> Can we get an option that is truly Snap and a separate one for extrapolate (which in my case is catastrophically bad)?

Sure, it’s possible, but someone needs to implement it. Please see [How are features and bug fixes incorporated into ParaView?](https://discourse.paraview.org/t/how-are-features-and-bug-fixes-incorporated-into-paraview/4735).
