I have data in EPSG 4978 (3D Cartesian XYZ using WGS84) and just for kicks, I tried projecting it to 4326 (lon, lat 2D using WGS84). I expected an error but lo and behold, I got a point back.
Here's my query to verify that my point is EPSG 4978:
=>select st_astext(pos_geom) from pos.pos_ts limit 1;
st_astext
------------------------------------------------------
POINT Z (1427635.07972 -5672506.90998 2534091.68628)
Attempt at transformation:
=> select st_astext(st_transform(pos_geom, 4326)) from pos.pos_ts limit 1;
st_astext
----------------------------------------------------------------
POINT Z (-75.8734015076523 23.5640490271681 -20.0468848655)
Like what?! My first reaction was that the output was probably garbage (-20.04688?) but when I use an external library to do the same transformation, it appears that the lon lat values are correct. So my question is twofold:
- What is PostGIS doing? AFAIK this behavior, while useful, violates the EPSG standard for 4326. 4326 is a 2D CRS with no Z coordinate in the spec.
- Please oh please tell me that the Z coordinate is elevation relative to the ellipsoid! I want it to be true but can't find it documented and my external projection method doesn't return elevation.