Latitude/Longitude compensating expression.
- September 22, 2023
- 2 replies
- 1570 views
I was trying to figure out how to create an accurate GPS location display for an animated path. I got almost everything figured out using some simple math, but the Longitude compensation was giving me problems. Here's the heart of the problem.
Latitude has nearly the same distance of about 69 miles per degree, no matter where you are. Longitude is not as easy. One degree of Longitude is also about 69 miles per degree at the equator, but at the poles, it is zero. As the Latitude increases from 0º to 90º, the distance per degree goes down, but the decrease is not linear because the measurement is on a sphere.
I tried all kinds of trigonometry but failed miserably, so I simplified everything by creating a new layer, offsetting the y Anchor Point value by 1 pixel. I then set up a rotation that matches the 0 to 90º values for Latitude. I then used toWorld to generate a multiplier from 1 to zero from the X position value. Here's the simple expression:
latComp = thisComp.layer("Longetude Factor");
latAngl = latComp.toWorld(anchorPoint)[0]-1-thisComp.width/2;
This gives me a simple way to accurately display distances based on the distance between two GPS locations or the distance traveled by a layer (a dot) following a path drawn on a map.
Does anyone have any idea how to do the same thing mathematically? When the Latitude is 45º, the multiplier should be about .707, so 1º = about 48 miles. I'd love to get this preset to work with just one layer.
Any help would be appreciated. It's been a long time since my Math Analysis and Trig classes. Here's a look at where I am so far:


