Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Programmers beware! You need to be especially careful with converting geodetic lat/lon/alt coordinates to and from other systems, particularly with the Earth-centered, Earth-fixed system (basically a Cartesian x,y,z coordinate grid). Do it incorrectly, and you might find yourself buried under several meters of dirt ;)

All too often I've come across code that started out by assuming a spherical Earth (wrong!) or trying to compensate by multiplying by a factor to adjust for the oblation (still wrong!). Doing this calculation accurately is very much non-trivial and still a topic of active research in geodesy.

Fortunately, there's libraries to do the hard work for you:

http://earth-info.nga.mil/GandG/geotrans/

http://geographiclib.sourceforge.net/



It gets better still! Did you know that GPS data and KML (Google Earth's format), despite both using the WGS84 spheroid, are not compatible? GPS computes altitude above the spheroid (shape of the earth), while KML requires altitude above the geoid (shape of the sea). These differ by several hundred feet in many areas. (The geoid is 30 m below the ellipsoid where I am.)

But wait there's more! Just using lat/long and ignoring elevation? Guess what, the verticals for GPS and KML differ too! GPS looks down a line normal to the spheroid; KML looks down a line normal to the geoid (in the direction of gravity). Those are almost always different. So unless your GPS readings were taken at sea level, your data's still wrong!

The picture here explains what's going on: http://en.wikipedia.org/wiki/Geoid#Description The "plumb lines" are what are used by KML; the other lines are what are used by GPS. Notice how they point to different locations...

(P.S. I'm not a GIS-icist, but this comes from experience of collecting and correcting GPS data and reading spec sheets. I'd love if an actual GIS or Google person told me I was wrong but I'm not holding my breath.)


I haven't used either of those libraries, but have used proj which did an excellent job of coordinate projections: http://trac.osgeo.org/proj/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: