I am currently working on a project (web app) at university to be able to calculate the amount of time spent during night flying. Currently, I have,
Departure Lat and Long and Departure Time in UTC
Arrival Lat and Long and Arrival Time in UTC Sunset and
Sunrise Times (Based on dates) for both Arrival and Departure airfields in UTC

An example:
Depart UK Edinburgh airport on the 23 April 2019 at 11:10 UTC
Arrive Saudi Arabia Riyadh Airport at 18:10 UTC Total Time 7hr
day flight = ?
night flight = ?

I know many places online do this type of calculation for you, so I am wondering if there is a formula or method available that allows me to do this calculation also taking into account the direction of travel etc (Which I can then convert to code)?

  • what gis software or code do you have?
    – Mapperz
    Oct 28, 2020 at 13:45

1 Answer 1


This Physics stack exchange post contains a link to this page, with an algorithm for calculating day/night with Lat, Lon and time. Using the formulas on this page you could calculate the lat lon, at timestamps, assuming a constant speed and great circle, and use them as inputs for the algorithm at the link above.

  • 1
    Thank you these help a lot, I think I have the right idea, so far I am plotting a GC course and then with the initial angle I am getting new Coordinates along the GC (around every 5 min of flight time) and then getting the Sunset and Sunrise times for each point as I go and seeing if I am in the night.
    – pilotman
    Oct 29, 2020 at 0:07
  • 1
    That sounds like what I worked out in my head, using the formula here: edwilliams.org/avform.htm#Intermediate If you calculate the total distance and know the start and stop time, you can calculate the fraction of the GC the plane will travel every 5 minutes and use that as input for the formulas in the link above. Keep in mind that if the GC goes far enough north or south, there may be more than one transition between night and day.
    – jgm_GIS
    Oct 29, 2020 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.