Search code examples
kmlgoogle-earthbearing

Google Earth bearing messed up


I don't know if this is supposed to happen, but it is definitely not what I want.

I have a python script that creates a kml file based on latitude, longitude and altitude from a database. Once the kml is created, everything looks fine, but the bearing gets messed up whenever you zoom out or get near +/- 90 latitude (the poles).

Does anyone know if this is a glitch with Google Earth or if this is how it is supposed to be? Does anyone know how to fix it?

Before you conclude that the arrows on Google Earth should reorient themselves, hear me out: the arrows on the map should point to the back of one another, and they do (most of the time). However, like I said, if you zoom out or get near the poles, then the arrows flip sideways.

I think the problem is that Google Earth assumes that the orientation of all of the Placemarks should be the same based on one Placemark, and thus the majority of the arrows point the wrong way in many instances.

Check this kml file out if you don't believe me... (Go to the north pole and move over it a couple of times and you should see what I am talking about.) (Also, after you download, right click and select open with... Google Earth - make sure you download it too.)

https://docs.google.com/file/d/0B_achbIA2bcBdnp5b3J3WlJ3U1U/edit?usp=drive_web

Any ideas?


Solution

  • In your KML file, you are specifying the icon heading in the <heading> tag inside <IconStyle>. To me, it looks like your computation of bearing is producing the undesirable results. Are you doing something `bearing = atan2( (lon2-lat2)/(lat2 - lat1) ) in your code? If so, your calculations will blow up near the poles (and the bearings will be inaccurate). I suspect you're doing this type of calculation because the arrows are misaligned with the track as you proceed higher in latitude where that bearing calculation's error increases.

    If you want to accurate compute bearing from subsequent lat-lon-alt pairs, I recommend converting the lat-lon-alt pairs into 3D Cartesian position vectors, approximating the velocity vector by finite difference, and then resolving the velocity direction in the North-East-Down coordinate system (or East-North-Up, if you prefer). Then you can solve accurately for bearing.

    tl;dr: It's not Google Earth that's messing up. I think it's your bearing calculation.