Converting Longitude/Latitude/Altitude to Cartesian Coords

2,877 views
Skip to first unread message

Zeeshan

unread,
Apr 2, 2008, 5:27:24 AM4/2/08
to KML Developer Support - Getting Started with KML
Hi,

I want to convert Longitude/Latitude/Altitude coordinates of a point
to x,y,z coordinates. Can anybody point to some mathematical formulae
to do the same?

Actually, I have some 3D models in Google Earth's .KMZ format; all
vertices stored in GE format are in Longitude/Lat./Alt. coordinate
system, and I want them in cartesian coordinates.

Thanks a lot in advance.

mwill

unread,
Apr 2, 2008, 8:35:21 AM4/2/08
to KML Developer Support - Getting Started with KML


Zeeshan,
This isn't quite a KML problem, unless you are having trouble
extracting the data from the KML. I did see that you dealt with a
similar situation (extracting data from a KML/KMZ) in another post.
If you are just asking about turning Lat/Long/Alt into x,y,z you
didn't provides us with enough information, but that can turn into an
advanced math question.

If each building doesn't need to have coordinates relative to each
other, I would suggest literally turning the Lat/Long/Alt into x,y,z
(meaning 12.34N/067.8W/5m becomes 12.34, 67.8,5). That would work
over small distances such as the dimensions of a building. If the
buildings need to be relative to each others, then that's too advanced
for me.

mwill

ManoM

unread,
Apr 2, 2008, 10:03:08 AM4/2/08
to KML Developer Support - Getting Started with KML
Hi Zeeshan,
As mwill points out, you can just convert them using longitude as the
x, latitude as the y, altitude as the z. I'm not actually sure of the
usefulness of doing that, but I'm sure you have something in mind.

The main problem is that longitude length is not the same at different
latitudes on the globe. They gradually decline to zero near the poles.
Wikipedia has formula for that:
http://en.wikipedia.org/wiki/Longitude#Degree_length

Mano

zeeshanzia84

unread,
Apr 6, 2008, 9:47:31 AM4/6/08
to KML Developer Support - Getting Started with KML
Thanks guys.

I am actually working on some 3D vision related applications.
Unfortunately, the sketchup file format is not opened by google. So, I
download sketchup files from 3D Warehouse and EXPORT them to the kml
format using Sketchup. Next, I open the kml files in a C++ program,
and try to apply some algorithms on them. I've succeeded in writing a
small parser which extracts 3D Models (a cup, or a car, or a table)
from the KML file. However, all of the faces are in Long./Lat./Alt.
format, and I just want a straightforward formula to convert from this
to Cartesian coordinate system. Nothing advanced like far apart
buildings or anything.
> > Thanks a lot in advance.- Hide quoted text -
>
> - Show quoted text -

mwill

unread,
Apr 6, 2008, 10:48:06 AM4/6/08
to KML Developer Support - Getting Started with KML

zeeshan,

I originally typed up a long post, but then I think I figured out
what you are looking for:

x (in m) = Latitude * 60 * 1852

y (in m) = (PI/180) * cos(Longitude) * ( 637813.7^2 /
sqrt( (637813.7 * cos(Longitude))^2 + (635675.23 *
sin(Longitude))^2 ) ) <--- from ManoM's link

z (in m) = Altitude (in m)

mwill

Zeeshan

unread,
Apr 7, 2008, 4:33:18 AM4/7/08
to KML Developer Support - Getting Started with KML
Thank you very much mwill. That really worked for me.
Reply all
Reply to author
Forward
0 new messages