Distance between coordinates
The coordinates returned from the Geolake API are a latitude and longitude in degrees in decimal form. The latitude is 0 at the Equator and goes to +90 at the
North Pole and -90 at the South Pole. The longitude is 0 at Greenwich, England and goes down to the west to -180 and up to the east to +180.
If you know the latitude and longitude for two points, you can calculate the distance between them. The easiest method to calculate this distance assumes that
the earth is a perfect sphere, which is not entirely true. The results will not be entirely correct, but they will be a reasonable approximation in many cases.
Precise distance calculation is more complicated, and depends on more accurate models of the earth. It's usually more convenient to use an existing library for
precise distance calculation.
Rough Approximation
1 degree of latitude ~= 69 miles (111 km), regardless of the longitude
1 degree of longitude ~= 69 miles (111 km) at the Equator where latitude = 0, but this varies by latitude
Per latitude:
Latitude +10 or -10, 1 degree of longitude = 68 miles (109km)
Latitude +20 or -20, 1 degree of longitude = 65 miles (104km)
Latitude +30 or -30, 1 degree of longitude = 60 miles (96km)
Latitude +40 or -40, 1 degree of longitude = v53 miles (85km)
Latitude +50 or -50, 1 degree of longitude = 44 miles (71km)
Latitude +60 or -60, 1 degree of longitude = 35 miles (56km)
Latitude +70 or -70, 1 degree of longitude = 24 miles (38km)
Latitude +80 or -80, 1 degree of longitude = 12 miles (19km)
Latitude +90 or -90, 1 degree of longitude = 0 miles/km
Excel distance approximation
- A2 = Latitude 1
- B2 = Longitude 1
- C2 = Latitude 2
- D2 = Longitude 2
Formula for distance in km:
=ACOS(SIN(RADIANS(C2))*SIN(RADIANS(A2))+COS(RADIANS(C2))*COS(RADIANS(A2))*COS(RADIANS((B2-D2))))*6371
Replace 6371 at the end with 3958.76 to get a distance in miles instead
Java code
Java precise distance
This example uses https://geographiclib.sourceforge.io/
Maven library dependency
Code