# Get scalar value at selected coordinate from interpolated polydata

**URL:** https://discourse.vtk.org/t/get-scalar-value-at-selected-coordinate-from-interpolated-polydata/9808
**Category:** Support
**Created:** [November 13, 2022, 10:18pm UTC](https://discourse.vtk.org/t/get-scalar-value-at-selected-coordinate-from-interpolated-polydata/9808 "2022-11-13T22:18:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Waldeinsamkeit83](https://discourse.vtk.org/user_avatar/discourse.vtk.org/waldeinsamkeit83/32/6021_2.png) [@Waldeinsamkeit83](https://discourse.vtk.org/u/Waldeinsamkeit83)
#### Post date: [November 13, 2022, 10:18pm UTC](https://discourse.vtk.org/t/get-scalar-value-at-selected-coordinate-from-interpolated-polydata/9808/1 "2022-11-13T22:18:17Z")

</div>

Hi,  
I used PointInterpolater example ( [https://kitware.github.io/vtk-examples/site/Cxx/Meshes/PointInterpolator](https://kitware.github.io/vtk-examples/site/Cxx/Meshes/PointInterpolator) ) code to visualize difference between 3d scanner point cloud data and nominal CAD data.

Is it possible to get scalar value at a picked coordinate on a surface?

Update:  
Here is a picture of my program. I randomly picked a coordinate(R3). Can I get the scalar value? Should I write my own probe function just like in the vtkPointInterpolator?

 ![pickedCoordinate](https://discourse.vtk.org/uploads/default/original/2X/8/815aaab21c8ce3639209cbf9674a1635c36158eb.png)  
Best regards,  
Emre

---

<div class="post-metadata">

### Author: ![Waldeinsamkeit83](https://discourse.vtk.org/user_avatar/discourse.vtk.org/waldeinsamkeit83/32/6021_2.png) [@Waldeinsamkeit83](https://discourse.vtk.org/u/Waldeinsamkeit83)
#### Post date: [November 14, 2022, 6:24pm UTC](https://discourse.vtk.org/t/get-scalar-value-at-selected-coordinate-from-interpolated-polydata/9808/2 "2022-11-14T18:24:25Z")

</div>

Hi,  
I did some digging and found a way to get scalar value for .  
Here is the code:

```auto
vtkNew<vtkPoints> ProbePoints;
ProbePoints->InsertNextPoint(/* Point on Interpolated PolyData */);

vtkNew<vtkPolyData> ProbePointPolyData;
ProbePointPolyData->SetPoints(ProbePoints);

vtkNew<vtkProbeFilter>;
ProbeFilter->SetSourceData(/* Interpolated PolyData*/ );
ProbeFilter->SetInputData(ProbePointPolyData);
ProbeFilter->Update();

vtkDataArray* data = ProbeFilter->GetOutput()->GetPointData()->GetScalars();
vtkDoubleArray* doubleData = dynamic_cast<vtkDoubleArray*>(data);

for (int i = 0; i < doubleData->GetNumberOfTuples(); i++)
{
      double val = doubleData->GetValue(i);
}

```

Best regards

---

<div class="post-metadata">

### Author: ![peeling](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/p/b5e925/32.png) [@peeling](https://discourse.vtk.org/u/peeling)
#### Post date: [November 15, 2022, 1:21pm UTC](https://discourse.vtk.org/t/get-scalar-value-at-selected-coordinate-from-interpolated-polydata/9808/3 "2022-11-15T13:21:25Z")

</div>

Hi  
I’m new to VTK and I have a similar question to yours,  
I have a data array of scalars values (of volume), how to know the corresponding coordinate (x or y or z) of each scalar in my array?  
`var values = reader.getOutputData().getPointData().getScalars().getData();`

Thank you

---

<div class="post-metadata">

### Author: ![Waldeinsamkeit83](https://discourse.vtk.org/user_avatar/discourse.vtk.org/waldeinsamkeit83/32/6021_2.png) [@Waldeinsamkeit83](https://discourse.vtk.org/u/Waldeinsamkeit83)
#### Post date: [November 15, 2022, 1:27pm UTC](https://discourse.vtk.org/t/get-scalar-value-at-selected-coordinate-from-interpolated-polydata/9808/4 "2022-11-15T13:27:48Z")

</div>

Hi Lucas

Actually it’s in the getPointData()  
Indexes are correspondent.

---

<div class="post-metadata">

### Author: ![peeling](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/p/b5e925/32.png) [@peeling](https://discourse.vtk.org/u/peeling)
#### Post date: [November 15, 2022, 2:08pm UTC](https://discourse.vtk.org/t/get-scalar-value-at-selected-coordinate-from-interpolated-polydata/9808/5 "2022-11-15T14:08:26Z")

</div>

I just have an array of 11927552 elements, I don’t know how we can differentiate indexes and say that is corresponding to X or Y or Z

![image](https://discourse.vtk.org/uploads/default/original/2X/3/3de041738974957f7176074e626910dbdb1090f8.png)
