# coordinate transformation problem

**URL:** https://discourse.paraview.org/t/coordinate-transformation-problem/193
**Category:** ParaView Support
**Created:** [June 16, 2018, 10:56pm UTC](https://discourse.paraview.org/t/coordinate-transformation-problem/193 "2018-06-16T22:56:37Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![zengwl17206](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/z/a87d85/32.png) [@zengwl17206](https://discourse.paraview.org/u/zengwl17206)
#### Post date: [June 16, 2018, 10:56pm UTC](https://discourse.paraview.org/t/coordinate-transformation-problem/193/1 "2018-06-16T22:56:40Z")

</div>

Hello everyone,

Here I have an xdmf file, whose data is described in polar coordinate (r, θ, φ) instead of (x, y, z). I want to do a coordinate transformation and display the data in Cartesian coordinate. By typing the following code in programmable filter:

from paraview import vtk

pdi = self.GetPolyDataInput()  
pdo = self.GetPolyDataOutput()  
newPoints = vtk.vtkPoints()  
numPoints = pdi.GetNumberOfPoints()  
for i in range(0, numPoints):  
coord = pdi.GetPoint(i)  
r, theta, phi = coord[:3]  
x = r\*sin(phi)_cos(theta)  
y = r_sin(phi)_sin(theta)  
z = r_cos(phi)  
newPoints.InsertPoint(i, x, y, z)  
pdo.SetPoints(newPoints)

I get the following error:  
Traceback (most recent call last):  
File “”, line 22, in   
File “”, line 9, in RequestData  
AttributeError: ‘vtkCommonDataModelPython.vtkMultiBlockDataSet’ object has no attribute ‘GetPoint’

Does anyone know how should I modify the code or is there any other way to do the coordinate transformation? Thank you so much.

–Yunlin

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dcthomp/32/20_2.png) [@dcthomp](https://discourse.paraview.org/u/dcthomp)
#### Post date: [June 17, 2018, 12:56pm UTC](https://discourse.paraview.org/t/coordinate-transformation-problem/193/2 "2018-06-17T12:56:28Z")

</div>

Multiblock datasets do not have a single set of points but rather a set of points for each block. You may either

- change your script to detect multiblocks and iterate over each block, transforming points for each dataset that inherits vtkPointSet or
- use the calculator filter with the “Coordinate Results” checkbox selected and a formula like `xCoord*sin(yCoord)*cos(zCoord)*iHat + ...`; the calculator filter automatically iterates over blocks for you.

The latter is simpler unless you need to perform additional processing.

---

<div class="post-metadata">

### Author: ![zengwl17206](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/z/a87d85/32.png) [@zengwl17206](https://discourse.paraview.org/u/zengwl17206)
#### Post date: [June 18, 2018, 3:00am UTC](https://discourse.paraview.org/t/coordinate-transformation-problem/193/3 "2018-06-18T03:00:21Z")

</div>

Hi David,  
Please excuse my ignorance. After I enter coordsX\*sin(coordsY)\*cos(coordsZ)_iHat + coordsX_sin(coordsY)\*sin(coordsZ)_jHat + coordsX_cos(coordsZ)\*kHat, the output error message says “Coordinate output specified, but output is not polydata or unstructured grid”, which I am not sure how to deal with. Thank you so much for help.

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dcthomp/32/20_2.png) [@dcthomp](https://discourse.paraview.org/u/dcthomp)
#### Post date: [June 18, 2018, 3:08am UTC](https://discourse.paraview.org/t/coordinate-transformation-problem/193/4 "2018-06-18T03:08:04Z")

</div>

Hi Yunlin,

It sounds like you have image or rectilinear data. These types of data do not store point coordinates explicitly. Instead, the coordinates are inferred from the (i,j,k) indices of the point. Since they aren’t stored explicitly, there is no place for the calculator filter to store its results.

There is a way to get around this in ParaView, but it is very inefficient. Before running the calculator filter, run the “clean to grid” filter. It will convert your data into an unstructured grid which _does_ store point coordinates explicitly. However, this will take up lots of memory. That could be a problem if your dataset is large.

---

<div class="post-metadata">

### Author: ![zengwl17206](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/z/a87d85/32.png) [@zengwl17206](https://discourse.paraview.org/u/zengwl17206)
#### Post date: [June 18, 2018, 6:00am UTC](https://discourse.paraview.org/t/coordinate-transformation-problem/193/5 "2018-06-18T06:00:34Z")

</div>

Thank you so much David! I think I’ve made it.

---

<div class="post-metadata">

### Author: ![monica](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/a183cd/32.png) [@monica](https://discourse.paraview.org/u/monica)
#### Post date: [February 20, 2019, 6:12pm UTC](https://discourse.paraview.org/t/coordinate-transformation-problem/193/6 "2019-02-20T18:12:35Z")

</div>

Hi David  
I have a 2D geometry file which is defined in cartesian coordinate (x,y). Now I want to convert that to 2D cylindrical coordinate (z,r). how can I do that?  
thanks

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dcthomp/32/20_2.png) [@dcthomp](https://discourse.paraview.org/u/dcthomp)
#### Post date: [February 21, 2019, 4:12pm UTC](https://discourse.paraview.org/t/coordinate-transformation-problem/193/7 "2019-02-21T16:12:39Z")

</div>

@monica A few things,

1. You can tell a Calculator filter to overwrite point coordinates with its result array using the “Coordinate Results” checkbox. Use iHat, jHat, and kHat to create a vector value for each point, however:
2. r-z cylindrical coordinates _are_ cartesian (assuming θ = constant). Perhaps you meant r-θ coordinates?
3. Next time, please start a new topic rather than responding to an existing one with a new question.

---

<div class="post-metadata">

### Author: ![swornom](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/cab0a1/32.png) [@swornom](https://discourse.paraview.org/u/swornom)
#### Post date: [April 27, 2021, 11:10pm UTC](https://discourse.paraview.org/t/coordinate-transformation-problem/193/8 "2021-04-27T23:10:21Z")

</div>

This is sorted related. When I do plot over a line. I would like to use the actual coordinates written on the PV files and NOT interpolated values (PV asks for the number of values for the line). Is this 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: [April 28, 2021, 8:50am UTC](https://discourse.paraview.org/t/coordinate-transformation-problem/193/9 "2021-04-28T08:50:48Z")

</div>


