# Find nearest geographic coordinates

Frank Muller frank.muller.erl@REDACTED
Fri Nov 27 08:24:22 CET 2020

```Thanks Richard. Happy to see you are still around and didn’t left the
Erlang community.

/Frank

Fri . 27 nov. 2020 03:57, Richard O'Keefe <raoknz@REDACTED> wrote :

> When I had something similar to do, I found the simplest
> thing was to convert latitude and longitude to (x,y,z)
> points on the unit sphere.  I then took advantage of the
> fact that great-circle distance on the surface of the
> sphere and chordal distance going through it are monotonically
> related, so the closest in 3-space is also the closest on the
> 2-sphere.  See
> https://en.wikipedia.org/wiki/Great-circle_distance
>
> The obvious question is SCALE:
> how many points will there be?
> how many queries will there be?
> For my application, storing the 3d points in a k-d-tree
> with k=3 worked OK, but it was hundreds of points,
> not millions.
>
> On Thu, 26 Nov 2020 at 10:39, Frank Muller <frank.muller.erl@REDACTED>
> wrote:
>
>> Hi guys,
>>
>> I've a list of geographic coordinates:
>>
>> L = [ {{<<"longitude">>,6.1457}, {<<"latitude">>,46.2022}},
>>       {{<<"longitude">>,2.3387}, {<<"latitude">>,48.8582}},
>>       ... ]
>>
>> and a specific coordinate X = {{<<"longitude">>,-73.5848},
>> {<<"latitude">>,45.4995}}.
>>
>> Question: how can i find the nearest coordinates to X from L (sorted from
>> the nearest to the farest)?
>>
>> /Frank
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20201127/ca13f34d/attachment.htm>
```