0

I have a surface of points in XYZ (all Z are 0), and I map these points onto a Sphere. So I have an XYZ coordinate for each point on the sphere.

What I want to achieve is the convert this XYZ sphere coordinate to its Lat/Long parallel, in terms of the Geographic location. So for example if I have the point (0,0,0) I want to see how to represent it as the South Pole at Lat/Long (90.0000° S, 45.0000° E).

I searched online and there are endless webpages that explain parts of this, but a lot of them talk about converting Lat/Long to XYZ and not the other way around. I'm not sure if there is a straightforward formula to convert one to another.

Hopefully someone can point me in the right direction.

Thanks

Yafim Simanovsky
  • 531
  • 7
  • 26
  • There is a so-called local NEU (north east up) coordinate system that complies with the one you call XYZ. NEU can be converted to earth-centered XeYeZe. From that XeYeZe, you can convert to (lat,long,H). – swatchai Nov 13 '20 at 04:13

1 Answers1

1

There is a so-called local ENU (east north up) coordinate system that complies with the one you call XYZ. ENU can be converted to earth-centered XeYeZe. From that XeYeZe, you can convert to (lat,long,H).

In Python you can use pymap3d to do all your required computation. Here is a runnable code that you can try.

import pymap3d
ell_wgs84 = pymap3d.Ellipsoid('wgs84')

# Your ENU system needs origin definition (lat0, lon0, h0) +
# and also needs a reference ellipsoid: let's use `ell_wgs84` defined above
lat0, lon0, h0 = -90, 45, 0   # origin of ENU, (h is height above ellipsoid)

# Test ENU coordinates: (e1, n1, u1) by `enu2geodetic()`
e1, n1, u1     =  0.0,  0.0,  0.0  # just the origin of this ENU system
lat1, lon1, h1 = pymap3d.enu2geodetic(e1, n1, u1, \
                                      lat0, lon0, h0, \
                                      ell=ell_wgs84, deg=True)  # use wgs86 ellisoid
# this should agree with: (lat0, lon0, h0)
print(lat1, lon1, h1)  # -90.0 44.99999999999999 1.313839409243646e-12  OK!

# Inversion check by `geodetic2enu()`
# input values to convert: lat1, lon1, h1
e1k, n1k, u1k = pymap3d.geodetic2enu(lat1, lon1, h1, lat0, lon0, h0, ell=ell_wgs84, deg=True)
print(e1k, n1k, u1k)   # 0,0,0  OK

# Now arbitrary ENU to lat/long and reverse
lat112, lon112, h112 = pymap3d.enu2geodetic(1120, 100, 10, \
                                      lat0, lon0, h0, \
                                      ell=ell_wgs84, deg=True)
print(lat112, lon112, h112)
# Check
e112k, n112k, u112k = pymap3d.geodetic2enu(lat112, lon112, h112, lat0, lon0, h0, ell=ell_wgs84, deg=True)
print(e112k, n112k, u112k)   # 1120, 100, 10 OK
swatchai
  • 17,400
  • 3
  • 39
  • 58
  • Hi, thanks! I'm using IronPython in a specific environment. Can't really use an external library like pymap3d. Is there a more manual way to do the calculation...? – Yafim Simanovsky Nov 13 '20 at 08:15
  • Then get some code from https://github.com/geospace-code/pymap3d/tree/master/src/pymap3d – swatchai Nov 13 '20 at 08:46