This may be slightly more complicated than you're expecting, and I apologize for not directly providing any formulas as I'm on mobile. The easy one is your northing. Latitude lines are all parallal, and what you could do is convert your start and end points from coordinate to radians, relative to the equator. Then multiply that difference by the radius of the earth. To be hyper-technical, the earth is not a sphere, but an oblate spheroid. Without the context of the distances you're covering, I would be shocked if that ended up making a practical difference. Easting is slightly more complicated, since the distance between longitude lines gets smaller the closer to the poles you are (I will assume you're referring to distances in the northern hemisphere). Again, the effect of this will depend on the distances being considered. The calculation of this distance would again be coordinate to radian, multiply by radius, however, this circle would only be the radius of the earth if the coordinates were on the equator. You would need a calculation to determine the radius of the horizontal section of the earth that that northing coordinate makes. You will get different answers depending on if you calculate this distance at the start or end northing. You'll have to use your judgement on which is appropriate for your use case. For the actual calculations, assuming you want these constrained to their own column and not have to create multiple dummy columns, the LET() function is your friend here. Answer from Aquat1cn1nja on reddit.com
🌐
NOAA
nhc.noaa.gov › gccalc.shtml
Latitude/Longitude Distance Calculator
Enter latitude and longitude of two points, select the desired units: nautical miles (n mi), statute miles (sm), or kilometers (km) and click Compute. 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.
🌐
Omni Calculator
omnicalculator.com › other › latitude-longitude-distance
Latitude Longitude Distance Calculator
January 18, 2024 - ... d = 2R × sin⁻¹(√[sin²((θ₂ - θ₁)/2) + cosθ₁ × cosθ₂ × sin²((φ₂ - φ₁)/2)]). ... The distance between any two adjacent latitudes is approximately 69 miles or 111 km.
Discussions

How can I calculate the distance between two points using Latitude and Longitude?
u/PercivalFailed - Your post was submitted successfully. Once your problem is solved, reply to the answer(s) saying Solution Verified to close the thread. Follow the submission rules -- particularly 1 and 2. To fix the body, click edit. To fix your title, delete and re-post. Include your Excel version and all other relevant information Failing to follow these steps may result in your post being removed without warning. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/excel
16
6
May 21, 2025
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
Distance between latitude and longitude points
I have a listing of latitude and longitude for all US zip code centroids. I want to find the distance between two zip codes using a simple formula in Excel. I have seen this formula in several… More on learn.microsoft.com
🌐 learn.microsoft.com
1
0
python - How can I quickly estimate the distance between two (latitude, longitude) points? - Stack Overflow
I want to be able to get a estimate of the distance between two (latitude, longitude) points. I want to undershoot, as this will be for A* graph search and I want it to be fast. The points will be at More on stackoverflow.com
🌐 stackoverflow.com
People also ask

What is the distance per degree of longitude?
The distance per degree of longitude at the Equator is about 111.32 km (69.18 miles) and at the poles, 0.
🌐
britannica.com
britannica.com › philosophy & religion › humanities
Latitude and longitude | Definition, Examples, Diagrams, & Facts ...
What is longitude?
Longitude is a measurement of location east or west of the prime meridian at Greenwich, London, England, the specially designated imaginary north-south line that passes through both geographic poles and Greenwich. Longitude is measured 180° both east and west of the prime meridian.
🌐
britannica.com
britannica.com › philosophy & religion › humanities
Latitude and longitude | Definition, Examples, Diagrams, & Facts ...
What is the distance between two consecutive latitudes?

The distance between any two adjacent latitudes is approximately 69 miles or 111 km. Latitude lines run parallel to each other. That's why the distance between them remains constant from the South to the North pole. On the other hand, longitude lines are furthest apart at the equator and meet at the poles.

🌐
omnicalculator.com
omnicalculator.com › other › latitude-longitude-distance
Latitude Longitude Distance Calculator
🌐
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. Get Results: The straight-line and driving distances will appear in the results panel.
🌐
Movable Type
movable-type.co.uk › scripts › latlong.html
Calculate distance and bearing between two Latitude/ ...
An accuracy of better than 3m in 1km is mostly good enough for me, but if you want greater accuracy, you could use the Vincenty formula for calculating geodesic distances on ellipsoids, which gives results accurate to within 1mm. (Out of sheer perversity – I’ve never needed such accuracy – I looked up this formula and discovered the JavaScript implementation was simpler than I expected). Trig functions take arguments in radians, so latitude, longitude, and bearings in degrees (either decimal or degrees/minutes/seconds) need to be converted to radians, rad = deg⋅π/180.
🌐
Reddit
reddit.com › r/excel › how can i calculate the distance between two points using latitude and longitude?
r/excel on Reddit: How can I calculate the distance between two points using Latitude and Longitude?
May 21, 2025 -

I have a list of locations and their latitude and longitudes. I want to compare them to a specific point and use a formula to output their distances from that point in terms of how many miles East and North of that point they are, not in a straight line beween them.

So I'd have my origin point and point A. Lines 2 and 3 would look something like this:

Name of Origin point | latitude O | longitude O | 0 | 0

Name of Point A | latitude A | longitude A | X (number of miles) | Y (number of miles)

What formulas would I use in columns D and E to calculate these distances?

Top answer
1 of 11
9
This may be slightly more complicated than you're expecting, and I apologize for not directly providing any formulas as I'm on mobile. The easy one is your northing. Latitude lines are all parallal, and what you could do is convert your start and end points from coordinate to radians, relative to the equator. Then multiply that difference by the radius of the earth. To be hyper-technical, the earth is not a sphere, but an oblate spheroid. Without the context of the distances you're covering, I would be shocked if that ended up making a practical difference. Easting is slightly more complicated, since the distance between longitude lines gets smaller the closer to the poles you are (I will assume you're referring to distances in the northern hemisphere). Again, the effect of this will depend on the distances being considered. The calculation of this distance would again be coordinate to radian, multiply by radius, however, this circle would only be the radius of the earth if the coordinates were on the equator. You would need a calculation to determine the radius of the horizontal section of the earth that that northing coordinate makes. You will get different answers depending on if you calculate this distance at the start or end northing. You'll have to use your judgement on which is appropriate for your use case. For the actual calculations, assuming you want these constrained to their own column and not have to create multiple dummy columns, the LET() function is your friend here.
2 of 11
6
Like this? Haversine formula seems to work... || || |Place|Latitude|Longitude|Distance KM|Distance Mi| |Toronto|43.651070|-79.347015|510.6768877|317.3234442| |Montreal-EST|45.630001|-73.519997||| Here you go: https://pastebin.com/raw/Cs72CSAJ
Find elsewhere
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,

import 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:

from 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.

🌐
USGS
usgs.gov › faqs › how-much-distance-does-a-degree-minute-and-second-cover-your-maps
How much distance does a degree, minute, and second cover on your maps? | U.S. Geological Survey
One degree of latitude equals approximately 364,000 feet (69 miles), one minute equals 6,068 feet (1.15 miles), and one-second equals 101 feet. One-degree of longitude equals 288,200 feet (54.6 miles), one minute equals 4,800 feet (0.91 mile), ...
🌐
ThoughtCo
thoughtco.com › degree-of-latitude-and-longitude-distance-4070616
The Distance Between Two Latitude and Longitude Coordinates
May 18, 2024 - At 40 degrees north or south, the distance between a degree of longitude is 53 miles (85 kilometers). The line at 40 degrees north runs through the middle of the United States and China, as well as Turkey and Spain.
🌐
Encyclopedia Britannica
britannica.com › philosophy & religion › humanities
Latitude and longitude | Definition, Examples, Diagrams, & Facts | Britannica
3 weeks ago - The distance per degree of longitude at the Equator is about 111.32 km (69.18 miles) and at the poles, 0. latitude and longitude, in cartography, a coordinate system used to determine and describe the position of any place on Earth’s surface.
🌐
Medium
medium.com › @manishsingh7163 › calculating-distance-between-successive-latitude-longitude-coordinates-using-pandas-287c15bc5029
Calculating Distance Between Successive Latitude-Longitude Coordinates using Pandas | by Manish Singh | Medium
March 18, 2024 - In this blog post, we’ll explore how to achieve this using Python, specifically with Pandas and the Haversine formula. ... The Haversine formula is a mathematical formula used to calculate the shortest distance between two points on a sphere ...
🌐
SunEarthTools
sunearthtools.com › tools › distance.php
Distance direction calculating between two location on the planet directly on the map
Drag the marker on map to calculate distance (km, meters, mile, foot) and bearing angle of direction on google map, between two points of the earth. Calculation of average speed or time spent. ... Valid value for the latitude are from -90.0° to 90.0° for the longitude are from -180.0° to ...
🌐
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.
🌐
Wikipedia
en.wikipedia.org › wiki › Haversine_formula
Haversine formula - Wikipedia
1 week ago - The haversine formula determines the great-circle distance between two points on a sphere given their longitudes and latitudes. Important in navigation, it is a special case of a more general formula in spherical trigonometry, the law of haversines, ...
🌐
MathWorks
mathworks.com › mapping toolbox › geometric geodesy › great circles, geodesics, and rhumb lines
distance - Distance between points on sphere or ellipsoid - MATLAB
This MATLAB function calculates the arc length arclen and azimuth az of the great circle arc from the starting point with coordinates lat1 and lon1 to the ending point with coordinates lat2 and lon2.
Top answer
1 of 8
125

The answers to Haversine Formula in Python (Bearing and Distance between two GPS points) provide Python implementations that answer your question.

Using the implementation below I performed 100,000 iterations in less than 1 second on an older laptop. I think for your purposes this should be sufficient. However, you should profile anything before you optimize for performance.

from math import radians, cos, sin, asin, sqrt
def haversine(lon1, lat1, lon2, lat2):
    """
    Calculate the great circle distance between two points 
    on the earth (specified in decimal degrees)
    """
    # convert decimal degrees to radians 
    lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
    # haversine formula 
    dlon = lon2 - lon1 
    dlat = lat2 - lat1 
    a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
    c = 2 * asin(sqrt(a)) 
    # Radius of earth in kilometers is 6371
    km = 6371* c
    return km

To underestimate haversine(lat1, long1, lat2, long2) * 0.90 or whatever factor you want. I don't see how introducing error to your underestimation is useful.

2 of 8
46

Since the distance is relatively small, you can use the equirectangular distance approximation. This approximation is faster than using the Haversine formula. So, to get the distance from your reference point (lat1, lon1) to the point you're testing (lat2, lon2) use the formula below:

from math import sqrt, cos, radians

R = 6371  # radius of the earth in km
x = (radians(lon2) - radians(lon1)) * cos(0.5 * (radians(lat2) + radians(lat1)))
y = radians(lat2) - radians(lat1)
d = R * sqrt(x*x + y*y)

Since R is in km, the distance d will be in km.

Reference: http://www.movable-type.co.uk/scripts/latlong.html

🌐
Google Support
support.google.com › docs › thread › 137329980 › how-to-calculate-distance-between-latitude-longitude-coordinates
How to calculate distance between latitude & longitude coordinates? - Google Docs Editors Community
Skip to main content · Google Docs Editors Help · Sign in · Google Help · Help Center · Community · Google Docs Editors · Terms of Service · Submit feedback · Send feedback on
🌐
AuraQ
auraq.com › distance-calculations-using-latitudes-and-longitudes
Distance calculations using latitudes and longitudes - AuraQ
October 18, 2022 - For this we need to use the Haversine formula. The Haversine formula finds great circle distance between two points given their latitudes and longitudes.