Help

Re: Great Circle Distance

1170 1
cancel
Showing results for 
Search instead for 
Did you mean: 
E_K
6 - Interface Innovator
6 - Interface Innovator

Is there some way to use only Airtable instruments to calculate the great circle distance between two points?
I have those points with lat and long coordinates and need a formula to calculate the great circle distance (or something close to it, no need in high precision).
I know the haversine formula, but lack of trigonometry functions in Airtable makes the whole thing impossible. I am not into scripts, zapiers and web-hooks unfortunately.
I have a Google API key which is used to create maps from Airtable data, but I do not need to calculate road distance or time, only great circle (use case is aviation).
Just a formula of any complexity would be great.
Thanks to everyone concerned.

2 Replies 2

Not possible (as you make clear).

You need to get into scripts - trust me; your life – especially with Airtable – will change.

You need only a couple of javascript functions in a script block to perform this geometric computation.

This is the Haversine function.

function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) {
  var R = 6371; // Radius of the earth in km
  var dLat = deg2rad(lat2-lat1);  // deg2rad below
  var dLon = deg2rad(lon2-lon1); 
  var a = 
    Math.sin(dLat/2) * Math.sin(dLat/2) +
    Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * 
    Math.sin(dLon/2) * Math.sin(dLon/2)
    ; 
  var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
  var d = R * c; // Distance in km
  return d;
}

function deg2rad(deg) {
  return deg * (Math.PI/180)
}

Thank you very much @Bill.French
I will try to figure out how to incorporate it in my base with zero scripting experience so far;-)