[GIS] GPS coordinates to XYZ on relative grid

coordinate systemgps

This has kind of been asked before in different ways, but I'm struggling to adapt the answers to my specific scenario.

Say I have a ground station and a plane in the sky. I know the GPS lat, lon, and altitude of both. I'm trying to derive the XYZ position of the plane relative to the ground station on a new grid system where the ground station sits at (0,0,0), the Z-axis points out of the ground station into the sky, the Y and X axis are tangent to the altitude of the ground station, and the Y axis projects over the north pole (points north when zoomed in close).

Here's a picture to try and convey this:

enter image description here

The orange dot is the ground station, the brown dot is the plane, and the red axes are how I'd like to define my new relative grid.

I tried doing this: Convert the lat/lon/alt to earth XYZ coordinates, then rotating about the earth Z axis by ground-station longitude, then rotating about the earth Y axis by ground-station latitude, then translating along earth X axis for ground-station altitude (plug earth radius). I then relabeled the axis: earth-X = Z2, earth-Y = X2, and earth-Z = Y2. I got a result that placed the ground station at (0,0,0), but the plane results don't look right: the altitudes shown on the Z-axis are out of order compared to the plane's GPS altitude readings. I'm testing with plane coordinates that are close enough to the ground station that the curvature of the earth should not affect the Z-axis very much (maybe a couple hundred feet, while these planes are at 5000ft to 48000 ft).

Best Answer

The method is elaborated in IOGP Guidance Note 373-07-2, Oct 2018, Pg 100-104.

Let's assume the followings:

  • G_phi, G_lam, G_eh be your Ground Station's lat, long, and ellipsoid height.
  • P_phi, P_lam, P_eh be your Plane's lat, long, and ellipsoid height.

Next, let's compute the followings (from the Ground Station and Plane geodetic coordinates):

  • Let gX, gY, gZ be the ECEF coordinates of your Ground Station.
  • Let pX, pY, pZ be the ECEF coordinates of your Plane.

Your Ground Station's ENU coordinate is E=0, N=0, U=0. So there is nothing to compute. Your Plane's ENU coordinates, relative to your Ground Station, is therefore (using the scalar form of the formula):-

  • E = (-1)(pX - gX)(sin G_lam) + (pY - gY)(cos G_lam)
  • N = (-1)(pX - gX)(sin G_phi * cos G_lam) - (pY - gY)(sin G_phi * sin G_lam) + (pZ - gZ)(cos G_phi)
  • U = (pX - gX)(cos G_phi * cos G_lam) + (pY - gY)(cos G_phi * sin G_lam) + (pZ - gZ)(sin G_phi)

(All geodetic coordinates are in radians.)

Reply to Comment

@rdb is dealing with altitudes (referring to some geoid)...

Questioner stated "GPS lat, lon, and altitude". Usually, this means ellipsoidal height. Moreover - Questioner used a plane as an example, hence unlikely the height is orthometric. =)

but turning polar to rectangular like a sphere, so it is not easy to write a correct answer.

Questioner was describing his approach which was unsuccessful. However, his/her description is not to be confused as his/her requirement to arrive at the correct answer.

Section 2.2.2 details the formulas discussed in your answer, to convert geocentric coordinates to topocentric ones, but first geographic coordinates must be converted into geocentric (section 2.2.1).

This is correct. My answer jumped directly into the ECEF coordinates (i.e., gX/gY/gZ and pX/pY/pZ), making the assumption that the Questioner knows how to convert phi/lambda/eh to ECEF XYZ. Moreover, Method 2.2.2 is chosen because it is easier to explain (and much less to type).

Related Question