Can I treat latitude/longitude as (x,y) coordinates to find closest point?

806 Views Asked by At

I have a list of coordinates L(lat, lon) and a specific position X.
I am interested in finding the nearest location from the list L to the position X.
Can I treat the lat, lon as x, y and implement the planar case approach?

2

There are 2 best solutions below

1
On

No, consider these two pairs of points in (lat, long):

  • $(0^\circ,0^\circ)$ and $(89.9^\circ,0^\circ)$
  • $(89.9^\circ, 0^\circ)$ and $(89.9^\circ, 180^\circ)$

The first pair is $89.9^\circ$ apart, and the second pair is $0.2^\circ$ apart, but the first pair in your $(x,y)$ coordinates is closer.

0
On

Just a hint

A better way would be to switch to cartesian coordinates in ${\mathbb R}^3$ and then approximate distance as length of difference between these cartesian vectors. But it would require many calculations of sin and cos functions to do so. Here is a more computationally saving approach.

If you allow yourself to do a local transformation, you can do rectangular transforms like those you see on globes. For example at the wikipedia page for Mercator Projection, consider the passage on small element geometry, where you can calculate x and y of corner points of a local patch, calculate linear scale factors to transfer $\phi,\theta$ to $x,y$ this in some sense compensates for the "stretch" that the cylindrical transform has done. The relative scale factor will be $\cos(\phi)$ which will only become catastrophic (go to $0 / \infty$) around the poles at $\phi=\pm90^\circ$. So you will need to switch coordinates, but given that the range of angles are rather small, you should be able to get a good approximation.