Calculate geographical location (latitude, longitude) from horizontal and equatorial coordinates, date and UT

Lets say I found myself in the middle of nowhere with small computer with some sort of offline astrometry engine (like locally installed astrometry.net). I have some sort of mount that precisely tells me about altitude and azimuth of where its pointing and camera that I can use to take a photo of stars, upload the photo to the computer and calculate right ascension and declination. I also know exact UT time and date. How can I calculate my geographical latitude and longitude?

I've tried using these equations:

sin(ALT) = sin(DEC)·sin(LAT) + cos(DEC)·cos(LAT)·cos(HA)
cos(AZ) = (sin(DEC) - sin(ALT)·sin(LAT))/(cos(ALT)·cos(LAT))
HA = LMST - RA
LMST = 100.46+0.985647*d+LON+15*UT //(UT is the universal time in decimal hours, d is decimal days from J200)


to solve for LAT and HA and then calculate LON from HA but I can't really transform those equations. Online calculators seem to fail as well. Are there any other way or equations for calculating location?

PS. I know there is easier way while using Sun location on the sky - I'm not interested in that. I'm only interested in calculating location based on stars locations.

EDIT: I'd prefer analytical solution but numerical solutions are welcome as well.

• Have you looked at the Marq Saint-Hilaire method and tried adopting it? It is intended to be used drawing on a chart, but really just boils down the computing the intersection of two lines (where the alt circle and az line cross). It uses an "assumed az" which you could replace with the real az. Pretty much all other methods rely on the Alt of multiple objects since az is difficult to determine accurately. The only other methods I can think of that use az are the noon sight/meridian crossing, which require the object to be at 0 or 180deg az, so not as useful. Feb 16 at 14:25
• @GregMiller No, I don't now much about navigation so mainly I was fiddling with transforming equations of horizontal/equatorial conversion to solve for LAT and LON. I'm also interested in methods that rely on positions of multiple objects if you have any examples in mind Feb 16 at 14:32
• Here's a method using the alt of multiple objects. An implementation example is on the home page under "digital sextant". celestialprogramming.com/snippets/twoStarFix.html Feb 16 at 15:49

You should select a number of stars you might want to use for position fixes, and make a table with their declinations and sidereal hour angles (SHAs). Then pick a reference time and note the Greenwich hour angle (GHA) of the first point of Ares. 00:00 on January 1 of the current year is a convenient reference time. For 2024 it's 100 degrees 9.1 arcminutes. For 2025 it will be 100 degrees 54.0 arcminutes. Over the course of 366 calendar days it advanced 360 degrees 44.9 arc minutes. Interpolate. The GHA of a star is the sum of its SHA and Aries' GHA. GHA is the west longitude of the point on Earth a celestial body is directly above. The latitude of the point a star is above is equal to its declination.

With accurate altitude, azimuth and geographical position (lat/log of the point where it's in zenith) you can get a fix with a single star. It's necessary to solve the spherical triangle with vertices at the North Pole, observer location, and star's GP. The triangle's side between the pole and star's GP is equal to 90 degrees minus the latitude of the GP. The side from the observer to the star's GP is equal to 90 degrees minus the altitude of the star. The angle at the observer is the azimuth of the star.

Using the law of sines for spherical triangles find the angle at the pole. Add that angle to the star's GHA to find observer's west longitude.

Then, knowing two angles and their opposite sides use one of Napier's Analogies to find the unknown side.

tan(c/2) = tan((a+b)/2) * cos((A+B)/2) / cos((A-B)/2)


Here c is the unknown side. a and b are the known sides. A and B are the known angles. Wikipedia's entry Spherical Trigonometry explains all. The observer's latitude is 90 degrees minus side c.

Knowing azimuth exactly is what makes the 1 star fix work. At sea the azimuth isn't known with anywhere near the accuracy of the altitude, which can be found to a fraction of an arcminute with a sextant (not a bubble sextant). Don't forget to correct apparent altitude for refraction.

Greg Miller's comments inspired me to explore numerical approaches. In the end I found myself using a kind of Monte Carlo method. Here's what it looks like:

I assume that I know exactly time, right ascension and declination of any point of my image, azimuth and alituted of the same point. I know that for given time, azimuth and alituted there is only one location from which I'll get the same right ascension and declination.

So I randomly generated ~1000 points on Earth and calculated RA and DEC for them and picked the closest one to my RADEC. Next I generated ~100 normally distributed points around the closest point (with sigma depending on angular distance from factual RADEC to calculated RADEC) and found the closest point. I repeated this for as long as angular distance between true RADEC and calculated is small enough.

• What's the purpose of the 1000 random points? Feb 24 at 22:57
• I've found it to be faster in python that way. Calculating RADEC for a 1000 starting points and picking the best one shaved few seconds as oppose to picking 1 starting point. Feb 26 at 8:25