[Paraview] Extract geographic coordinates from spherical data

Sean J. Williams seanw at lanl.gov
Mon Mar 14 13:40:17 EDT 2011


> One point I noticed with this sphere grid is that is defined as an
> unstructured grid but I am unclear why? The longitudes range from 0-360
> and perhaps it expects things in -180/180 format?

On the first question, my (admittedly myopic) experience is that ParaView
is mostly only happy doing arbitrary coordinate transforms on unstructured
data -- which really makes sense, since you could move the coordinates
into positions that don't map onto any regular grid.

The three main trig functions (sin, cos, and tan) are periodic, such that
the [-180, 0] range is equivalent to the [180, 360] range. The only real
difference for a [-180, 180] longitude range is that everything is shifted
by a half-period, but as long as your data account for that, it doesn't
matter.

> If I slice the unstructured grid all I get are the sphere coordinates and
> the values. How can I readily convert these back to geographic?

I think terminology is getting confused, which happens to me often enough,
so I'll try and make things more explicit. Spherical coordinates are
coordinates of (theta, phi, radius), or in your case, something like
(longitude, latitude, radius). Cartesian coordinates are in (x, y, z),
which is how we usually think about the world. If you have the Earth
looking like the Earth (i.e., a rendering of your data looks like a
sphere), you're in Cartesian coordinates. On the other hand, if you have a
flat Earth, so that the x-axis is values of longitude on a range of e.g.
[-180, 180], you're in spherical coordinates.

So I assume your question is that you're in Cartesian coordinates (Earth
looks like the Earth) and you want to get back to spherical (flat Earth).
I haven't dealt with this myself, but the Wiki says the transformation is:

radius = sqrt(x^2 + y^2 + z^2)
longitude = acos(z / radius)
latitude = atan(y / x)

Note that this will probably put latitude on a [0, 180] range (since
that's how math people, being disconnected from any real application of
spherical coordinates, define them), so you'll probably want to subtract
90 from the resulting latitude to make sure that 0 degrees latitude is the
equator.

-Sean


More information about the ParaView mailing list