Is there packaged code to convert geographical coordinates (e.g.,
longitude, latitude, elevation) to Cartesian coordinates in 3-space?
[In] the C code underlying spTransform(), you'll see that the call to
pj_transform() sets z to zero, that is to the datum surface, and the
returned values are discarded.
ISTM "The Better Way" would be to add a boolean argument: e.g.,
spTransform(..., 3d=false, ...)
* make the current behavior the default
* for 3d=true, don't discard the elevations
Am I missing something?
The most robust route forward might be to permit 3D SpatialPoints to
be transformed directly, and choose a geo-centric target projection.