Length between GPS-locations

Hey all Unity developers and programmers :slight_smile: i am developing a game where i need the length between two GPS-locations in KM.
lets say we have two locations points like this:
(87.090329, 25.883993)
(89.393944, 31.92494)
how can i get the length between these two positions? anyone know?
if you could code it for me in c#

Best Regards :slight_smile:

The most common solution is to approximate using the Haversine formula.

Pseudo-code:

var a = sin²(Δφ/2) + cos φ1 * cos φ2 * sin²(Δλ/2);
var c = 2 * atan2( √a, √(1−a) );
var d = R * c;

where:
φ is latitude, λ is longitude, R is radius of the Earth (use 6,371km if unsure)

The easiest way I would think is get a map of a place you need…

Such the entire USA.

Okay, find the points of GPS you would like.
Then find a line of sight distance, then divide the distance or something like that.

That way you can calculate the distance per grid.