# Finding Latitude and Longitude of a person or of where a picture was taken

this is my first post on the Astronomy stack exchange site. Please let me know how this question is based on y'all's generally accepted criteria for a good question as well as possible improvements.

In my AP comp sci class we were given pretty much total freedom to come up with a project, I remembered hearing about it being possible to calculate a person's position or the position a picture was taken based on time of day and the position of the Sun, that is, longitudinal and latitudinal position. For the picture, I heard Sun position was determined through some implementation of shadows in the picture. I thought this was cool and decided to look into it. I found an article written by a prominent UCLA physicist and a well-researched Wikipedia page. I understand what the Wikipedia page requires in regards to values for calculations and what the equations calculate, but I do not understand how to implement them to find longitudinal and latitudinal location, nor do I understand why it has rectangular equatorial coordinates as that is not included in the three-step explanation in the Wikipedia page intro at the top.

For the UCLA report, I understand none of it except for the matrix mathematics and manipulations, and I'm sketchy on those at best, but I do not understand all the coordinate systems that it mentions nor how to implement them to achieve my objective.

So my question comes down to this: Can anyone clarify the equations, their purpose, their implementation, how to convert an answer to longitude and latitude for either the Wikipedia page or the UCLA report?

OR

If you can explain how to find the latitude and longitude of a picture or person. If you choose to explain, I do need equations or an explanation that I can turn into equations.

Please suggest question revisions and whether this should be posted on a different Stackexchange forum. Thanks.

• Sorry about lack of tags, dont know what else could be put in here May 16 '15 at 1:18
• This is rather unspecific. You appear to be asking someone to do your project... May 16 '15 at 15:40
• far from it @RobJeffries. I spent the past few flu-riddled days trying to understand UCLA research paper and googling various ways to achieve my goal, and I have reached a point where I am so frustrated I am considering changing my project and doing something different. I apologize if the question would it sound as such. What wording/paragraphs give it that air? May 16 '15 at 21:55
• And I do believe I now understand the calculations outlined in the Wikipedia page, my only issue is taking the answers and making that final conversion to latitude and longitude because it does not seem to be outlined in the Wiki page. I merely want someone to either clarify the final conversion step to latitude and longitude from the Wiki calculations, help me understand the UCLA research paper, or provide me with an answer of their own through use of equations, or a non-equation explanation that I can turn into an equation without too much trouble. May 16 '15 at 21:58
• You might be overthinking this. To convert from right ascension and declination to altitude and azimuth is a rigid rotation that depends on your location and time. You can do this rotation by converting to rectangular coordinates, rotating, and converting back to spherical coordinates, or you can just give the final answer as a translation from spherical coordinates to spherical coordinates.
– user21
May 17 '15 at 2:49

EDIT: It turns out I answered this question earlier (in a slightly different format):

Cancelling out earth rotation speed, Altazimuth mount

Imagine you are at 35N,106W at 5h local sidereal time.

The celestial north pole is at (0,90) in the celestial frame and (0,35) in your frame.

The point (5h,0) is (75,0) in the celestial sphere (1h = 15 degrees), and (180,55) in your frame

The point (11h,0) is (165,0) in the celestial sphere and (90,0) (setting in the east) in your frame.

Converting to rectangular coordinates, we need the matrix that does this:

{0,0,1} -> {Cos[35 Degree], 0, Sin[35 Degree]}

{Cos[75*Degree],Sin[75*Degree],0} -> {-Sin[35 Degree], 0, Cos[35 Degree]}

{Sin[-75*Degree],Cos[75*Degree],0} -> {0,1,0}


or, generalizing a bit (lst = local sidereal time as an angle, lat = latitude, notice that lon is irrelevant since we're using local sidereal time)

{0,0,1} -> {Cos[lat], 0, Sin[lat]}

{Cos[lst],Sin[lst],0} -> {-Sin[lat], 0, Cos[lat]}

{-Sin[lst],Cos[lst],0} -> {0,1,0}


Solving (Mathematica):

m0 = Table[a[i,j],{i,1,3},{j,1,3}]

(* Some simplifying assumptions, intentionally avoiding corner cases *)

conds = {-Pi/2 < dec < Pi/2, -Pi/2 < lat < Pi/2, 0 < ra < 2*Pi, -Pi < lst < Pi}

m = Simplify[m0 /. Solve[{
m0.{0,0,1} == {Cos[lat], 0, Sin[lat]},
m0.{Cos[lst],Sin[lst],0} == {-Sin[lat], 0, Cos[lat]},
m0.{-Sin[lst],Cos[lst],0} == {0,1,0}
},Flatten[m0]],conds]

m = m[[1]]


This gives us

$\left( \begin{array}{ccc} -\cos (\text{lst}) \sin (\text{lat}) & -\sin (\text{lat}) \sin (\text{lst}) & \cos (\text{lat}) \\ -\sin (\text{lst}) & \cos (\text{lst}) & 0 \\ \cos (\text{lat}) \cos (\text{lst}) & \cos (\text{lat}) \sin (\text{lst}) & \sin (\text{lat}) \\ \end{array} \right)$

The inverse of this matrix:

$\left( \begin{array}{ccc} -\cos (\text{lst}) \sin (\text{lat}) & -\sin (\text{lst}) & \cos (\text{lat}) \cos (\text{lst}) \\ -\sin (\text{lat}) \sin (\text{lst}) & \cos (\text{lst}) & \cos (\text{lat}) \sin (\text{lst}) \\ \cos (\text{lat}) & 0 & \sin (\text{lat}) \\ \end{array} \right)$

will transform rectangular azimuth and elevation back to right ascension and declination and right ascension. This would be an interesting alternative approach to this problem, but I won't be using it.

OK, if we convert right ascension and declination to rectangular coordinates, multiply by the first matrix above and convert the result back to spherical coordinates, we will have azimuth and elevation. Let's do that...

The spherical coordinates for (ra,dec) are:

{Cos[dec] Cos[ra], Cos[dec] Sin[ra], Sin[dec]}


Multiplying by the matrix, we get

$\{\sin (\text{dec}) \cos (\text{lat})-\cos (\text{dec}) \sin (\text{lat}) \cos (\text{lst}-\text{ra}),-\cos (\text{dec}) \sin (\text{lst}-\text{ra}),\cos (\text{dec}) \cos (\text{lat}) \cos (\text{lst}-\text{ra})+\sin (\text{dec}) \sin (\text{lat})\}$

(note that lst-ra is sometimes called the "hour angle", which would simplify the above)

Converting back to spherical coordinates and simplifying:

{x,y,z} = Simplify[m.{Cos[dec] Cos[ra], Cos[dec] Sin[ra], Sin[dec]},conds]

(* NOTE: the use of single argument arctangent here introduces
ambiguity, and the final answer must compensate for this *)

az = Simplify[ArcTan[y/x],conds]

el = Simplify[ArcSin[z],conds]


yielding:

$\text{azimuth}=-\tan ^{-1}\left(\frac{\cos (\text{dec}) \sin (\text{lst}-\text{ra})}{\sin (\text{dec}) \cos (\text{lat})-\cos (\text{dec}) \sin (\text{lat}) \cos (\text{lst}-\text{ra})}\right)$

$\text{elevation}=\sin ^{-1}(\cos (\text{dec}) \cos (\text{lat}) \cos (\text{lst}-\text{ra})+\sin (\text{dec}) \sin (\text{lat}))$

Assuming I haven't made any mistakes, the next steps would be:

• Converting local time to local sidereal time

• Inverting these equations to get latitude and longitude from azimuth, elevation, and time.

I may or may not edit this answer to add those steps, but this hopefully provides a start.

• holy muffincakes thats a lot of math. thanks. I will check through the answer and dechiper the wonderfulness May 18 '15 at 16:25
• I have not yet applied the answer, but it will obviously be the most helpful. So, just to be clear, I can use this to solve for latitude and longitude correct? May 19 '15 at 0:35
• Yes, you'll have to follow the two additional steps I mention. I may end up doing this myself later, since it's related to something I'm working on anyway.
– user21
May 19 '15 at 3:35
• thats cool. I've always found astronomy cool, so this was a chance to play with it. Thank you for the answer and Im def going to work on it. Doesn't look like it will be my project, but I have the summer for this as well May 20 '15 at 0:11
• Of course, in real life, if you're willing to go step by step and don't need a closed form solution, just fire up stellarium and set it to the known date/time and tweak the location until the sun position matches the position in the picture.
– user21
May 24 '15 at 16:59