Note: These formulas have been transcribed from EPSG Guidance Note #7-2. Users are encouraged to use that document rather than the text which follows as reference because limitations in the transcription will be avoided.
The forward case is trivial. A 3-dimensional geographic coordinate reference system comprising of geodetic latitude, geodetic longitude and ellipsoidal height is converted to its 2-dimensional subset by the simple expedient of dropping the height. The axis order change operates on coordinates of a point whose order change is described by the following matrix operation:
[Derived CRS 1st coordinate] [1 0 0] [Base CRS 1st coordinate]
[Derived CRS 2nd coordinate] = [0 1 0] * [Base CRS 2nd coordinate]
[Derived CRS 3rd coordinate] [0 0 0] [Base CRS 3rd coordinate]
The reverse conversion, from 2D to 3D, is indeterminate. It is however a requirement when a geographic 2D coordinate reference system is to be transformed using a geocentric method which is 3-dimensional. In practice an artificial ellipsoidal height is created and appended to the geographic 2D coordinate reference system to create a geographic 3D coordinate reference system referenced to the same geodetic datum. The assumed ellipsoidal height is usually either set to the gravity-related height of a position in a compound coordinate reference system, or set to zero. As long as the height chosen is within a few kilometres of sea level, no error will be induced into the horizontal position resulting from the later geocentric transformation; the vertical coordinate will however be meaningless.