# Converting Rectilinear Grid data type with spherical coordinates into Spherical representation

**URL:** https://discourse.paraview.org/t/converting-rectilinear-grid-data-type-with-spherical-coordinates-into-spherical-representation/4442
**Category:** ParaView Support
**Created:** [May 28, 2020, 5:49pm UTC](https://discourse.paraview.org/t/converting-rectilinear-grid-data-type-with-spherical-coordinates-into-spherical-representation/4442 "2020-05-28T17:49:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![wildecats](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/e68b1a/32.png) [@wildecats](https://discourse.paraview.org/u/wildecats)
#### Post date: [May 28, 2020, 5:49pm UTC](https://discourse.paraview.org/t/converting-rectilinear-grid-data-type-with-spherical-coordinates-into-spherical-representation/4442/1 "2020-05-28T17:49:12Z")

</div>

I am a new ParaView user and would like to understand how to get ParaView to represent the data file I am using in a spherical format. The background is as follows: I initially received a .FITS file containing data on the Sun’s magnetic field. A friend helped me to convert this into a .vtr file so I could view it using ParaView. The .vtr file I have is of type “Rectilinear Grid” and represents its coordinates as X, Y, Z, where each point/cell stores a magnetic field vector which represents the X,Y,Z components of the magnetic field magnitude at that point. When I view this data in ParaView as a Surface, it looks like a simple 3-D rectangular cube. However, the X,Y, and Z coordinates actually represent the radial, latitudinal, and longitudinal coordinates in relation to the Sun. Thus, when I view this data in ParaView, it would make more sense to see a 3-D sphere so each point can be plotted appropriately according its radius, latittude, and longitude. This is what I am not sure how to do. I am guessing the issue could be with the initial creation of the .vtr file. Perhaps instead of creating it as a “Rectilinear Grid” it should have been created as a “Curvilinear Grid”. If so, is there a way in Paraview to automatically convert a Rectilinear Grid to a Curvilinear Grid, or would I need to re-generate the .vtr file from scratch. If anyone has any helpful suggestions/resources, please let me know. By the way, I have reviewed the Paraview Guide to see if I could find an answer there, but did not see anything that directly answered by questions. Also, I tried to upload the file I am working with, but was not able to because I think its too large (96MB) for upload. Thanks so much.

---

<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: [May 29, 2020, 1:37am UTC](https://discourse.paraview.org/t/converting-rectilinear-grid-data-type-with-spherical-coordinates-into-spherical-representation/4442/2 "2020-05-29T01:37:24Z")

</div>

IMO you need to regenerate your dataset correctly from the original file. There is no filter convert from X,Y,Z to spherical.

However, you can implement this conversion in a simple Programmable filter if you know all the parameters to compute it.

---

<div class="post-metadata">

### Author: ![jfavre](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jfavre](https://discourse.paraview.org/u/jfavre)
#### Post date: [May 29, 2020, 6:27am UTC](https://discourse.paraview.org/t/converting-rectilinear-grid-data-type-with-spherical-coordinates-into-spherical-representation/4442/3 "2020-05-29T06:27:15Z")

</div>

you will find some useful source code in this old blog article

> **[ParaView’s Python Programmable Filters in Geophysics - Kitware Blog](https://blog.kitware.com/paraviews-python-programmable-filters-in-geophysics/)**
>
> With the ability to write data sources and filters in Python code within a ParaView pipeline, we are able to quickly prototype added functionality that ... Read More

---

<div class="post-metadata">

### Author: ![wildecats](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/e68b1a/32.png) [@wildecats](https://discourse.paraview.org/u/wildecats)
#### Post date: [June 7, 2020, 5:57am UTC](https://discourse.paraview.org/t/converting-rectilinear-grid-data-type-with-spherical-coordinates-into-spherical-representation/4442/4 "2020-06-07T05:57:23Z")

</div>

Hi Mathieu,

Sorry for my slow reply on this. Thanks for your suggestions. I am new to using Programmable Filters and need to educate myself on how to use those effectively. Regarding your first suggestion that I need to regenerate the dataset correctly from the original file, does this mean that I need to convert the original dataset from Spherical (Radius, Theta, Phi) to Cartesian (X,Y,Z) using the standard equations for this (i.e. X = R sin (theta) cos (phi), etc.) and then load the Cartesian data into Paraview? Currently, I have loaded the Radius coordinate as Z, the Phi coordinate as X, and the Theta coordinate as Y, which is incorrect and is why the data looks like a cube when it should really look like a sphere.

Jean- thanks for sharing the blog post. I found it a bit confusing, but hopefully it will make more sense as I get more familiarity/practice with using programmable filters in the first place.

---

<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: [June 8, 2020, 1:59am UTC](https://discourse.paraview.org/t/converting-rectilinear-grid-data-type-with-spherical-coordinates-into-spherical-representation/4442/5 "2020-06-08T01:59:59Z")

</div>

> [@wildecats](#):
>
> Regarding your first suggestion that I need to regenerate the dataset correctly from the original file, does this mean that I need to convert the original dataset from Spherical (Radius, Theta, Phi) to Cartesian (X,Y,Z) using the standard equations for this (i.e. X = R sin (theta) cos (phi), etc.) and then load the Cartesian data into Paraview?

Yes, this was my suggestion.
