function to convert 3D geographical coordinates to Cartesian?
On Sun, 30 Dec 2012, Tom Roche wrote:
Is there packaged code to convert geographical coordinates (e.g., longitude, latitude, elevation) to Cartesian coordinates in 3-space? The spherical-to-Cartesian math is straightforward enough, but there's certainly scope for error, so I'd prefer to use tested, previously-used code if available.
Have you searched the PROJ.4 list archives? My guess is that the problem is intractable, because your apparent elevation at the geographical coordinate point is crucially dependent on the datum. If the datum is unknown, then no geodetic transformation will be well-defined. If you do have the datum, that would help. This looks rather like backwards GPS, so maybe a GPS text would point to appropriate algorithms? If you look at 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. The most robust route forward might be to permit 3D SpatialPoints to be transformed directly, and choose a geo-centric target projection. If you have a data set case with both the input and matching output data, I could take a look. Best wishes, Roger
TIA, Tom Roche <Tom_Roche at pobox.com>
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Department of Economics, NHH Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no