🌐
Omni Calculator
omnicalculator.com › other › latitude-longitude-distance
Latitude Longitude Distance Calculator
January 18, 2024 - Let's assume we want to find the distance between these two European cities. First, we need to find their coordinates: Paris: Lat: 48.8566° N, Long: 2.3522° E. Krakow: Lat: 50.0647° N, Long: 19.9450° E. After typing the coordinates in the calculator, we obtain that the distance between Paris and Krakow is 1275.6 km or 792.6 miles.
🌐
Meridian Outpost
meridianoutpost.com › resources › etools › calculators › calculator-latitude-longitude-distance.php
Latitude / Longitude Distance Calculator | Distance Between Two Coordinates
Calculate the straight-line distance between two latitude and longitude coordinates in miles, kilometers, and nautical miles. Also convert decimal degrees to DMS and view both points on a map.
Discussions

math - How to convert latitude or longitude to meters? - Stack Overflow
I stumbled upon this question wanting to do SQL queries on latitude and longitude and found this great article with some Java code at the bottom. It might interest you as well. ... Most of the answers here are using simple spherical trigonometry, so the results are rather crude compared to the WGS84 ellipsoid distances used in the GPS system. Some of the answers refer to Vincenty's formula for ellipsoids, but that algorithm was designed for use on 1960s' era desk calculators ... More on stackoverflow.com
🌐 stackoverflow.com
Calculate distance in meters when you know longitude and latitude in java - Stack Overflow
You might want to specify if you ... want the distance as presented on the site. I'm sorry I don't exactly recall their names. However, the code seems relatively straightforward. ... I used the code from this site successfully: * Longditude and latitude calculation I had to make some calculations on the answers to make it into european meters, but that ... More on stackoverflow.com
🌐 stackoverflow.com
calculate distance using latitude and longitude excel
Posted by u/Ok-Cover7273 - 8 votes and 13 comments More on reddit.com
🌐 r/excel
13
8
September 14, 2022
python - Getting distance between two points based on latitude/longitude - Stack Overflow
I tried implementing the formula in Finding distances based on Latitude and Longitude. The applet does good for the two points I am testing: Yet my code is not working. from math import sin, cos, ... More on stackoverflow.com
🌐 stackoverflow.com
People also ask

How accurate is this Distance Calculator?
The straight-line ("as the crow flies") distance is calculated with high precision using the Haversine formula, a standard for spherical trigonometry. Driving distances are based on current road network data from mapping services. All results are estimates; actual travel can vary due to traffic, construction, or other real-time factors.
🌐
latlongdata.com
latlongdata.com › home › distance calculator
Distance Calculator - Latitude Longitude Data
How is distance calculated between coordinates?
This tool calculates great-circle distance between two latitude and longitude points.
🌐
meridianoutpost.com
meridianoutpost.com › resources › etools › calculators › calculator-latitude-longitude-distance.php
Latitude / Longitude Distance Calculator | Distance Between Two ...
How do I calculate the distance between two points with longitude and latitude?

To calculate the distance between two points given longitude and latitude coordinates:

  1. Write down each point's coordinates in degrees-only format. We'll call θ and φ to their respective latitude and longitude components.

  2. Input them in the haversine distance formula:

    d = 2R × sin⁻¹(√[sin²((θ₂ - θ₁)/2) + cosθ₁ × cosθ₂ × sin²((φ₂ - φ₁)/2)]).

    where:

    • (θ₁, φ₁) and (θ₂, φ₂) – Each point's coordinates;
    • R – Earth's radius; and
    • d – Great circle or 'as the crow flies' distance between the points.
🌐
omnicalculator.com
omnicalculator.com › other › latitude-longitude-distance
Latitude Longitude Distance Calculator
🌐
Spatial Thoughts
spatialthoughts.com › 2013 › 07 › 06 › calculate-distance-spreadsheet
Calculate distance between a pair of lat/lon coordinates – Spatial Thoughts
June 4, 2024 - You can structure your point coordinates into 4 columns Lat1, Lon1, Lat2, Lon2 in decimal degrees and the distance will be calculated in meters. You can give it a try. Just open this spreadsheet, make a copy it and play with it as you like.
🌐
Movable Type
movable-type.co.uk › scripts › latlong.html
Calculate distance and bearing between two Latitude/Longitude points using haversine formula in JavaScript
(Out of sheer perversity – I’ve ... and bearings in degrees (either decimal or degrees/minutes/seconds) need to be converted to radians, rad = deg⋅π/180....
🌐
NOAA
nhc.noaa.gov › gccalc.shtml
Latitude/Longitude Distance Calculator
Latitudes and longitudes may be entered in any of three different formats, decimal degrees (DD.DD), degrees and decimal minutes (DD:MM.MM) or degrees, minutes, and decimal seconds (DD:MM:SS.SS). Important Note: The distance calculator on this page is provided for informational purposes only.
🌐
CSG Network
csgnetwork.com › gpsdistcalc.html
GPS Latitude and Longitude Distance Calculator
GPS Latitude and Longitude Distance Calculator · This converter and calculator requires the use of Javascript enabled and capable browsers. It is designed to convert the two different and distinct methods of co-ordinate nomenclature from one methodology to the other, and to calculate the distance ...
🌐
Latitude Longitude Data
latlongdata.com › home › distance calculator
Distance Calculator - Latitude Longitude Data
November 6, 2025 - This tool provides two distinct distance measurements. Follow these steps for use. ... In the "Start Location" field, enter a full address, city, or latitude/longitude coordinates in decimal format (e.g., 34.0522, -118.2437). In the "End Location" field, enter the destination address or coordinates using the same format. Click Calculate: Press the "Calculate" button to process the inputs.
Find elsewhere
🌐
Calculator.net
calculator.net › home › math › distance calculator
Distance Calculator
The calculators below can be used to find the distance between two points on a 2D plane or 3D space. They can also be used to find the distance between two pairs of latitude and longitude, or two chosen points on a map.
🌐
LDDGO
lddgo.net › en › convert › distance
Longitude and Latitude Distance Calculator Online
Formula : Choose whether to use the Vincenty formula (ellipsoidal model) or the Haversine formula (spherical model) to calculate the distance between two latitude and longitude. Result Unit : Select the unit of distance, support meter (m), kilometer (km), mile (mi), nautical mile (nMi).
🌐
Reddit
reddit.com › r/excel › calculate distance using latitude and longitude excel
r/excel on Reddit: calculate distance using latitude and longitude excel
September 14, 2022 - =ACOS(COS(RADIANS(90-Lat1)) * COS(RADIANS(90-Lat2)) + SIN(RADIANS(90-Lat1)) * SIN(RADIANS(90-Lat2)) * COS(RADIANS(Long1-Long2))) * 6371 · but if you have others method tell me (looking for distane not road map) ...
Top answer
1 of 13
454

The Vincenty distance is now deprecated since GeoPy version 1.13 - you should use geopy.distance.distance() instead!


Some previous answers were based on the haversine formula, which assumes the earth is a sphere, which results in errors of up to about 0.5% (according to help(geopy.distance)). The Vincenty distance uses more accurate ellipsoidal models, such as WGS-84, and is implemented in geopy. For example,

Copyimport geopy.distance

coords_1 = (52.2296756, 21.0122287)
coords_2 = (52.406374, 16.9251681)

print(geopy.distance.geodesic(coords_1, coords_2).km)

will print the distance of 279.352901604 kilometers using the default ellipsoid WGS-84. (You can also choose .miles or one of several other distance units.)

2 of 13
319

Just as a note, if you just need a quick and easy way of finding the distance between two points, I strongly recommend using the approach described in Kurt's answer instead of reimplementing Haversine—see his post for rationale.

This answer focuses just on answering the specific bug the OP ran into.


It's because in Python, all the trigonometry functions use radians, not degrees.

You can either convert the numbers manually to radians, or use the radians function from the math module:

Copyfrom math import sin, cos, sqrt, atan2, radians

# Approximate radius of earth in km
R = 6373.0

lat1 = radians(52.2296756)
lon1 = radians(21.0122287)
lat2 = radians(52.406374)
lon2 = radians(16.9251681)

dlon = lon2 - lon1
dlat = lat2 - lat1

a = sin(dlat / 2)**2 + cos(lat1) * cos(lat2) * sin(dlon / 2)**2
c = 2 * atan2(sqrt(a), sqrt(1 - a))

distance = R * c

print("Result: ", distance)
print("Should be: ", 278.546, "km")

The distance is now returning the correct value of 278.545589351 km.

🌐
Boulter
boulter.com › gps › distance
Coordinate Distance Calculator
This tool will help you calculate the distance between two coordinates or a single point and a set of coordinates. I built this primarily to make it easy to check if a Locationless (Reverse) Cache has already been found.
Top answer
1 of 4
11

The tool seems to be just calculating the Euclidean distance between the two points (the square root of the sum of the squared differences between the coordinates). This doesn't make any sense for latitudes and longitudes, which are not coordinates in a Cartesian coordinate system. Not only is this number not a meaningful distance, but it no longer contains the information required to reconstruct a distance from it, so you won't be able to calculate anything meaningful from it; you need to go back to the latitudes and longitudes themselves.

To calculate distances between points given by latitudes and longitudes precisely, you need to know which geoid was used as a reference in specifying them. But since you only want to get within 95% of the answer, you can safely assume that the Earth is a sphere.

There are two possible meanings for "the distance between two points" on a sphere. You can take the Euclidean distance between the two points (the actual points, not their latitude/longitude coordinates like your tool does), or you can take distance along the shortest curve along the surface of the Earth. Again, if you only want to get to within 95% of the answer and the distances are as small as in your example, the difference is negligble, so you can take the Euclidean distance, which is easier to calculate.

To get the Euclidean distance, you can first calculate the Cartesian coordinates of the points from their latitudes and longitudes. Denoting the latitude by $\theta$, the longitude by $\phi$ and the Earth's radius by $R$ (with $R\approx 6371 \mathrm{km}$), these are given by

$$\vec{r}=\left(\begin{array}{c}x\\y\\z\end{array}\right) = \left(\begin{array}{c} R\cos\theta\cos\phi \\ R\cos\theta\sin\phi \\ R\sin\theta \end{array}\right)\;. $$

Then you get the distance between them using

$$d(\vec{r_1},\vec{r_2})=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}\;.$$

Since you seem to have small distances and aren't interested in precision, you can simplify this by expanding the trigonometric functions around one of the points, or, for greater precision, around the midpoint $\theta=(\theta_1+\theta_2)/2$, $\phi=(\phi_1+\phi_2)/2$:

$$\vec{r_2}-\vec{r_1}\approx R\left(\begin{array}{c} \sin\theta\cos\phi(\theta_2-\theta_1)-\cos\theta\sin\phi(\phi_2-\phi_1) \\ \sin\theta\sin\phi(\theta_2-\theta_1)+\cos\theta\cos\phi(\phi_2-\phi_1) \\ \cos\theta(\theta_2-\theta_1) \end{array}\right)\;, $$

$${}$$

$$\lvert\vec{r}_2-\vec{r}_1\rvert\approx R\sqrt{(\theta_2-\theta_1)^2 + \cos^2\theta(\phi_2-\phi_1)^2}\;.$$

2 of 4
5

If the distances are small, you can use the linearized version: $\Delta x=R \cos(\theta)\Delta \phi, \Delta y=R \Delta \theta$, where $x$ is east-west distance, $\theta$ is latitude (measured with zero at the equator), $y$ is north-south distance, and $\phi$ is longitude. Then the distance is $d=\sqrt{\Delta x^2+ \Delta y^2}$ in whatever units you used for $R$.

🌐
GeoDataSource
geodatasource.com › distance-calculator
City Lookup / Distance Calculator Demo | GeoDataSource
We also provide tutorials on how to calculate the distance between 2 locations using PHP, Ruby, Python, JavaScript, Java, .NET and C#. ... Subscribe to our newsletter and stay up to date with the latest news and deals!
🌐
OpenCage
opencagedata.com › tools › distance-between-two-points
Find the distance between two geographic points
A form allowing you to calculate the distance between two geographic coordinate (latitude, longitude) points in kilometers and miles.
Top answer
1 of 16
1405

This link might be helpful to you, as it details the use of the Haversine formula to calculate the distance.

Excerpt:

This script [in Javascript] calculates great-circle distances between the two points – that is, the shortest distance over the earth’s surface – using the ‘Haversine’ formula.

function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) {
  var R = 6371; // Radius of the earth in km
  var dLat = deg2rad(lat2-lat1);  // deg2rad below
  var dLon = deg2rad(lon2-lon1); 
  var a = 
    Math.sin(dLat/2) * Math.sin(dLat/2) +
    Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * 
    Math.sin(dLon/2) * Math.sin(dLon/2)
    ; 
  var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
  var d = R * c; // Distance in km
  return d;
}

function deg2rad(deg) {
  return deg * (Math.PI/180)
}
2 of 16
519

I needed to calculate a lot of distances between the points for my project, so I went ahead and tried to optimize the code, I have found here. On average in different browsers my new implementation runs 2 times faster than the most upvoted answer.

function distance(lat1, lon1, lat2, lon2) {
  const r = 6371; // km
  const p = Math.PI / 180;

  const a = 0.5 - Math.cos((lat2 - lat1) * p) / 2
                + Math.cos(lat1 * p) * Math.cos(lat2 * p) *
                  (1 - Math.cos((lon2 - lon1) * p)) / 2;

  return 2 * r * Math.asin(Math.sqrt(a));
}

You can play with my jsPerf and see the results here.

Recently I needed to do the same in python, so here is a python implementation:

from math import cos, asin, sqrt, pi

def distance(lat1, lon1, lat2, lon2):
    r = 6371 # km
    p = pi / 180

    a = 0.5 - cos((lat2-lat1)*p)/2 + cos(lat1*p) * cos(lat2*p) * (1-cos((lon2-lon1)*p))/2
    return 2 * r * asin(sqrt(a))

And for the sake of completeness: Haversine on Wikipedia.