Distance data - PiAware - Lat/Lon

Hi again all, your favourite newbie…

Having lots of fun with my PiAware, and just wondering about the distance column in the flight table tracker. Its only every empty from what Ive seen, so wondering if a) its missing for any reason and b) if there is a way of calculating the distance based on the lat/lon recorded in comparison to my receiver.

Id just like to select (from my JSON feed), aircraft that came within say 10 miles of me, is the scenario Im trying to create.

Many thanks for any advice or guidance as usual.


Actually think I might have it with a python module named GeoPy.


coords_1 = (52.2296756, 21.0122287)
coords_2 = (52.406374, 16.9251681)

Might be useful for someone if it works :smiley:

Or if you’re feeling really funky and math orientated…

from math import sin, cos, sqrt, atan2, radians

# approximate radius of earth in km
R = 6373.0

lat1 = radians(52.2296756)
lon1 = radians(21.0122287)
lat2 = radians(52.406374)
lon2 = radians(16.9251681)

dlon = lon2 - lon1
dlat = lat2 - lat1

a = sin(dlat / 2)**2 + cos(lat1) * cos(lat2) * sin(dlon / 2)**2
c = 2 * atan2(sqrt(a), sqrt(1 - a))

distance = R * c

print("Result:", distance)

It’s missing because you probably don’t have your location set in dump1090. How you do that depends on whether you are using the piaware image or the package install.

Once it is set, the distance field will be populated. If you want to select aircraft within a certain distance then you’ll have to use the data in aircraft.json and the haversine formula which you’ve already found.

please note that, once populated, the distance is from the receiver to the AC without taking altitude into account. Also, the distance will be in nautical miles by default.

Awesome, thanks guys. Much appreciate you replying and your responses. Very helpful as always.

Yes @caius I did the piaware image, so I’ll have to look into how I set that up. Did a quick search on my pi for the config file, but it didnt popup up straight away.

Thanks again :smiley:

Ooops, messaged again too soon. Yesterday i updated MyADB settings through FA, and low and behold I have distance and MLAT this morning.

So that looks like problem solved! Thanks guys!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.