Reputation: 636
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
Upvotes: 0
Views: 1049
Reputation: 18812
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
Upvotes: 1