Bookmarks    
nPr and nCr    
Random Number    
SD Calculator    
Sample Size    
Percent Error    
Density    
Molarity    
Molar Mass    
Ohm's Law    
Watts to Amps    
Voltage Drop    
Long Division    
Mixed Numbers    
Rounding    
Nth Root    
Exponents    
Half-Life    
Polar Form    
De Moivre    
3D Distance    
Point to Line    
Cross Product    
Determinant    
Sin Cos Tan    
Triangle Area    
Scale Factor    
Sector Area    
Ellipse Area    
Cube Volume    
Box Volume    
Sphere Volume    
Cone Volume    
Pipe Volume    
Time Duration    
Time Card    
Present Value    
Future Value    
Churn Rate    
A/B Test Calc    
SEO Traffic    
Ideal Weight    
Fat Intake    
Child Height    
Golf Handicap    
Heat Index    
Wind Chill    
Dew Point    
Download Time    
kWh to Cost    
AC Size (BTU)    
Heating Costs    
LED Savings    
Trip Gas Cost    
Tire Size    
Solar Output    
Solar Payback    
Battery Size    
Wall Area    
Gravel Needed    
Mortar Mix    
Slope Grade    
Curtain Size    
Soil Needed    
Sod Needed    
Ramp Length    
Blind Size    
Drain Slope    
Board Feet    
Heat Loss    
Furniture Fit    
Moving Boxes    
Plywood Cuts    
Shelf Sag    
   Add
Probability and random number calculators
Independent Events
Independent Events
Two Events Solver
Two Events Solver
Repeated Trials
Repeated Trials
Bayes' Theorem
Bayes' Theorem
Expected Value
Expected Value
Binomial Distribution
Binomial Distribution
nPr and nCr
nPr and nCr
Circular Permutation
Circular Permutation
With Repetition
With Repetition
Random Number
Random Number
Averages and statistics calculators
Average Calculator
Average Calculator
Mean Median Mode
Mean Median Mode
SD Calculator
SD Calculator
Quartiles & IQR
Quartiles & IQR
Frequency Table
Frequency Table
Correlation (r)
Correlation (r)
Normal Probability
Normal Probability
Z-Score Calculator
Z-Score Calculator
Confidence Interval
Confidence Interval
Sample Size
Sample Size
Mark & Recapture
Mark & Recapture
P-Value Calculator
P-Value Calculator
Percentage and ratio calculators
Percentage Calc
Percentage Calc
Percent Change
Percent Change
Percent Difference
Percent Difference
Percent Error
Percent Error
Ratio Calculator
Ratio Calculator
Discount Calculator
Discount Calculator
Sales Tax Calculator
Sales Tax Calculator
Margin Calculator
Margin Calculator
Speed calculators
Speed Calculator
Speed Calculator
Density and concentration calculators
Density
Density
Molarity
Molarity
Molar Mass
Molar Mass
Physics and electricity calculators
Ohm's Law
Ohm's Law
Watts to Amps
Watts to Amps
Resistor Colors
Resistor Colors
Voltage Drop
Voltage Drop
Unit conversion calculators
Weight Converter
Weight Converter
Shoe Size Converter
Shoe Size Converter
Integer and signed number calculators
Long Division
Long Division
LCM Calculator
LCM Calculator
GCF Calculator
GCF Calculator
Integer Calculator
Integer Calculator
Prime Factorization
Prime Factorization
Diophantine Solver
Diophantine Solver
Modulo Calculator
Modulo Calculator
Factor Calculator
Factor Calculator
Roman Numerals
Roman Numerals
Fraction, decimal and rounding calculators
Fraction Calculator
Fraction Calculator
Mixed Numbers
Mixed Numbers
Simplify Fractions
Simplify Fractions
Fraction to Decimal
Fraction to Decimal
Decimal to Fraction
Decimal to Fraction
Rounding
Rounding
Equation and inequality calculators
Linear Equation
Linear Equation
Linear Systems
Linear Systems
Quadratic Formula
Quadratic Formula
Absolute Value
Absolute Value
Quadratic Inequality
Quadratic Inequality
Polynomial calculators
Binomial Theorem
Binomial Theorem
Square root and nth root calculators
Simplify Radicals
Simplify Radicals
Nth Root
Nth Root
Exponent and logarithm calculators
Exponents
Exponents
Log Calculator
Log Calculator
Number of Digits
Number of Digits
Scientific Notation
Scientific Notation
Sci. Notation Math
Sci. Notation Math
Half-Life
Half-Life
Complex number calculators
Complex Numbers
Complex Numbers
Polar Form
Polar Form
De Moivre
De Moivre
Function and graph calculators
Slope Calculator
Slope Calculator
Linear Function
Linear Function
Direct & Inverse Variation
Direct & Inverse Variation
y = ax² Calculator
y = ax² Calculator
Distance Formula
Distance Formula
3D Distance
3D Distance
Section Formula
Section Formula
Point to Line
Point to Line
Lat/Long Distance
Lat/Long Distance
Complete the Square
Complete the Square
Circle Equation
Circle Equation
Conic Sections
Conic Sections
Polar Coordinates
Polar Coordinates
Sequence calculators
Arithmetic Sequence
Arithmetic Sequence
Geometric Sequence
Geometric Sequence
Fibonacci Sequence
Fibonacci Sequence
Recurrence Relation
Recurrence Relation
Vector calculators
Vector Calculator
Vector Calculator
Cross Product
Cross Product
Matrix calculators
Matrix Calculator
Matrix Calculator
Determinant
Determinant
Inverse Matrix
Inverse Matrix
Plane geometry calculators
Sin Cos Tan
Sin Cos Tan
Degrees ⇔ Radians
Degrees ⇔ Radians
a sin θ + b cos θ
a sin θ + b cos θ
Triangle Solver
Triangle Solver
Triangle Area
Triangle Area
Right Triangle
Right Triangle
Pythagorean Theorem
Pythagorean Theorem
Polygon Angles
Polygon Angles
Scale Factor
Scale Factor
Parallel Lines
Parallel Lines
Rectangle Area
Rectangle Area
Parallelogram Area
Parallelogram Area
Trapezoid Area
Trapezoid Area
Circle Calculator
Circle Calculator
Sector Area
Sector Area
Inscribed Angle
Inscribed Angle
Ellipse Area
Ellipse Area
Solid geometry calculators
Cube Volume
Cube Volume
Cube Surface Area
Cube Surface Area
Box Volume
Box Volume
Box Surface Area
Box Surface Area
Cylinder Volume
Cylinder Volume
Cylinder Surface
Cylinder Surface
Sphere Volume
Sphere Volume
Sphere Surface
Sphere Surface
Spherical Cap Volume
Spherical Cap Volume
Cap Surface Area
Cap Surface Area
Ellipsoid Volume
Ellipsoid Volume
Ellipsoid Surface
Ellipsoid Surface
Pyramid Volume
Pyramid Volume
Pyramid Surface
Pyramid Surface
Cone Volume
Cone Volume
Cone Surface Area
Cone Surface Area
Frustum Volume
Frustum Volume
Frustum Surface Area
Frustum Surface Area
Pipe Volume
Pipe Volume
Capsule Volume
Capsule Volume
Capsule Surface Area
Capsule Surface Area
Date and time calculators
Age Calculator
Age Calculator
Days Between Dates
Days Between Dates
Date Calculator
Date Calculator
Hours From Now
Hours From Now
Day of the Week
Day of the Week
Time Calculator
Time Calculator
Time Zone Converter
Time Zone Converter
Hours Calculator
Hours Calculator
Time Duration
Time Duration
Time Card
Time Card
Finance and economics calculators
Compound Interest
Compound Interest
Simple Interest
Simple Interest
Interest Calculator
Interest Calculator
TVM Calculator
TVM Calculator
Present Value
Present Value
Future Value
Future Value
ROI Calculator
ROI Calculator
IRR Calculator
IRR Calculator
Payback Period
Payback Period
Average Return
Average Return
GDP Calculator
GDP Calculator
Web marketing and ad metric calculators
CTR Calculator
CTR Calculator
Conversion Rate
Conversion Rate
CPC, CPM & CPA
CPC, CPM & CPA
ROAS Calculator
ROAS Calculator
Break-Even CPA
Break-Even CPA
LTV Calculator
LTV Calculator
CAC Calculator
CAC Calculator
Churn Rate
Churn Rate
A/B Test Calc
A/B Test Calc
A/B Sample Size
A/B Sample Size
SEO Traffic
SEO Traffic
Break-Even Point
Break-Even Point
Markup vs. Margin
Markup vs. Margin
CAGR Calculator
CAGR Calculator
Health and fitness calculators
BMI Calculator
BMI Calculator
Sleep Calculator
Sleep Calculator
Calorie Calculator
Calorie Calculator
BMR Calculator
BMR Calculator
TDEE Calculator
TDEE Calculator
Ideal Weight
Ideal Weight
Body Fat Calculator
Body Fat Calculator
Lean Body Mass
Lean Body Mass
Calories Burned
Calories Burned
Protein Intake
Protein Intake
Macro Calculator
Macro Calculator
Carb Calculator
Carb Calculator
Fat Intake
Fat Intake
Child Height
Child Height
Sports calculators
Golf Handicap
Golf Handicap
Pace Calculator
Pace Calculator
1RM Calculator
1RM Calculator
Target Heart Rate
Target Heart Rate
Weather calculators
Heat Index
Heat Index
Wind Chill
Wind Chill
Dew Point
Dew Point
Computer calculators
Base Converter
Base Converter
Subnet Calculator
Subnet Calculator
Download Time
Download Time
Household energy and budget calculators
Electricity Cost
Electricity Cost
kWh to Cost
kWh to Cost
Yearly kWh to Cost
Yearly kWh to Cost
AC Size (BTU)
AC Size (BTU)
AC Running Cost
AC Running Cost
Heating Costs
Heating Costs
Gas vs Electric
Gas vs Electric
LED Savings
LED Savings
Salary Calculator
Salary Calculator
Budget Calculator
Budget Calculator
Car calculators
Trip Gas Cost
Trip Gas Cost
EV Charging Cost
EV Charging Cost
EV vs Gas Cost
EV vs Gas Cost
MPG Calculator
MPG Calculator
Tire Size
Tire Size
Solar power and battery calculators
Solar Output
Solar Output
Solar Panel Count
Solar Panel Count
Solar Payback
Solar Payback
Battery Size
Battery Size
Home and DIY calculators
Tile Calculator
Tile Calculator
Stair Calculator
Stair Calculator
Concrete Volume
Concrete Volume
Wall Area
Wall Area
Wallpaper Rolls
Wallpaper Rolls
Paint Calculator
Paint Calculator
Flooring Needed
Flooring Needed
Exterior Walls
Exterior Walls
Gravel Needed
Gravel Needed
Mortar Mix
Mortar Mix
Slope Grade
Slope Grade
Lumber Cut List
Lumber Cut List
Lot Coverage/FAR
Lot Coverage/FAR
Sheet Vinyl Roll
Sheet Vinyl Roll
Insulation Needed
Insulation Needed
Curtain Size
Curtain Size
TV Size & Distance
TV Size & Distance
Soil Needed
Soil Needed
Sod Needed
Sod Needed
Block Calculator
Block Calculator
Brick Calculator
Brick Calculator
Deck Materials
Deck Materials
Ramp Length
Ramp Length
Pilot Hole Size
Pilot Hole Size
Room Ventilation
Room Ventilation
Paint Thinning
Paint Thinning
Baseboard & Trim
Baseboard & Trim
Blind Size
Blind Size
Picture Hanging
Picture Hanging
Drain Slope
Drain Slope
Screw Calculator
Screw Calculator
Board Feet
Board Feet
Fence Calculator
Fence Calculator
Wood Shrinkage
Wood Shrinkage
Caulk Calculator
Caulk Calculator
Heat Loss
Heat Loss
Furniture Fit
Furniture Fit
Moving Boxes
Moving Boxes
Storage Capacity
Storage Capacity
Plywood Cuts
Plywood Cuts
Shelf Sag
Shelf Sag

Latitude and Longitude Distance Calculator (Decimal and DMS)

Enter the latitude and longitude of two points to get the distance between them along the Earth's surface in km and miles. You can switch the input between decimal degrees and DMS.

Fill in every field with numbers. In decimal form, south latitudes and west longitudes are negative (for example, 77.0366° W → −77.0366). In DMS form, choose N/S and E/W from the drop-downs.
Result
Enter the latitude and longitude of the two points in the fields on the left and press "Calculate". The result will appear here.

What you can do on this page

  • Enter the latitude and longitude of two points, and you get the distance between them along the Earth's surface (in miles and km) on the spot
  • You can enter decimal degrees (for example, 40.7128) or degrees, minutes and seconds (DMS, for example, 40°42′46.08″). Switch with the radio buttons
  • The distance is calculated with Lambert's formula, which treats the Earth as an ellipsoid (a slightly flattened sphere). This is closer to the real Earth than the haversine formula, which treats the Earth as a perfect sphere
  • A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are also on this page
The result is the approximate length of the shortest path along the Earth's surface (the geodesic), not the travel distance along roads or railways. In decimal form, enter south latitudes and west longitudes as negative numbers (all of the US has negative longitudes).

What is this calculation used for?

Flight routes and flight distances (aviation)

Airplanes fly close to the shortest path along the curve of the Earth (the great-circle route), so the flight distance between cities is estimated as a distance along the Earth's surface, like the one on this page (New York to London is about 3,470 miles, or 5,585 km). Airline mileage charts are based on this kind of distance too.
On a flat map, flights from the US to Asia seem to take a detour over Alaska and near the Arctic. Calculating this distance shows why that path is actually the shortest.

Location services on your phone ("near me" searches)

When a map or delivery app sorts places by "nearest first", it calculates the distance between your location and each store from their latitudes and longitudes. In programming, the haversine formula (sphere model) is the standard tool for this, and ellipsoid formulas like Lambert's formula on this page are used when more accuracy is needed.
Behind the apps you use every day, this kind of formula is calculated over and over.

GPS distance in running and hiking apps (sports)

A GPS watch or running app records your position every few seconds, calculates the distance between each pair of points with this kind of formula, and adds them up. Each step is only tens of feet, but the latitude-and-longitude-to-distance conversion is repeated thousands of times to show "you ran 6.2 miles today".

Voyage planning and nautical miles (shipping and logistics)

At sea, distance is measured in nautical miles (1 nautical mile = 1.852 km, about 1.15 miles, roughly the length of 1 minute of latitude). The route from the departure port to the destination is planned as a distance along the curve of the Earth, and arrival times and fuel estimates start from this distance calculation.
Shipping carries much of the world's trade, and latitude and longitude distances are part of what keeps it running.

"X miles from the epicenter" in earthquake reports (safety)

Earthquake reports such as "the epicenter was 12 miles southwest of the city" come from the same kind of calculation: the distance between the latitude and longitude of the epicenter (the point on the surface directly above the quake) and those of each town or monitoring station.
Knowing in numbers how far your home is from active faults and past epicenters is a good first step in preparing for earthquakes.

Formula

Central angle \(c\) between the two points (Lambert's formula, part 1)
Standard notation (the usual math form)
\(U\) \(=\) \(\arctan\bigl((1 - f)\tan \varphi\bigr)\)
\(c\) \(=\) \(2\arcsin\sqrt{\sin^2\!\frac{U_2 - U_1}{2} + \cos U_1 \cos U_2 \sin^2\!\frac{\lambda_2 - \lambda_1}{2}}\)
In words (symbols replaced with words)
② \(U\): reduced latitude \(=\) ① latitude \(\varphi\) shrunk by the flattening \(f\)
④ \(c\): central angle between the two points \(=\) ③ angle made from the differences in reduced latitude and longitude
The formula in words
① For each of the two points, calculate the latitude \(\varphi\) shrunk by the flattening \(f\), \(\arctan((1-f)\tan\varphi)\)
② to get the reduced latitude \(U\) (\(U_1\) and \(U_2\)). Next, calculate the
③ angle made from the reduced latitude difference \(U_2 - U_1\) and the longitude difference \(\lambda_2 - \lambda_1\)
④ and you get the central angle \(c\) between the two points (the angle between the two points as seen from the center of the Earth)
Quick example
The central angle between New York (40.7128° N, 74.0060° W) and Washington, D.C. (38.8976° N, 77.0366° W) is
central angle \(c\) \(=\) angle from the differences in reduced latitude and longitude of New York and D.C.
\(U_1 = \arctan\bigl((1 - \tfrac{1}{298.257})\tan 40.7128^\circ\bigr) \approx 40.6177^\circ, \quad U_2 \approx 38.8036^\circ\)
\(c = 2\arcsin\sqrt{0.00066425} \approx 0.051552 \ \mathrm{rad} \ (\approx 2.9537^\circ)\)
Key idea
The Earth is not a perfect sphere. Its equatorial radius is about 3,963 miles (6,378 km) and its polar radius is about 3,950 miles (6,357 km), so it is squashed from north to south by about 1/300. This shape is called an ellipsoid of revolution. The flattening \(f = \dfrac{1}{298.257}\) measures how squashed it is, and if you put the latitude straight into a formula for a sphere, the result is off by this amount. So first each latitude is converted into the reduced latitude \(U\), a latitude adjusted so that the ellipsoid can be treated like a sphere. Then the standard formula for the central angle between two points on a sphere (a haversine-type formula) is used. When you program it, writing \(c = 2\,\mathrm{atan2}(\sqrt{a},\ \sqrt{1-a})\) (where \(a\) is the expression under the root) gives the same value as \(2\arcsin\sqrt{a}\), but is more numerically stable. The calculator on this page uses this form.
Correction for the ellipsoid and the distance \(d\) (Lambert's formula, part 2)
Standard notation (the usual math form)
\(d\) \(=\) \(3963.15\) \(\times\) \(\bigl(\) \(c\) \(-\) \(\frac{f(X + Y)}{2}\) \(\bigr)\)
In words (symbols replaced with words)
④ \(d\): distance between the two points \(=\) ③ equatorial radius, 3963.15 mi \(\times\) \(\bigl(\) ① \(c\): central angle \(-\) ② flattening correction \(f(X+Y) \div 2\) \(\bigr)\)
The formula in words
① From the central angle \(c\) (in radians)
② subtract the flattening correction \(f(X+Y) \div 2\) (\(X\) and \(Y\) are in-between values for the correction)
③ multiply by the equatorial radius, 3963.15 mi
④ and you get the distance \(d\) between the two points (in miles; use 6378.1 km for the radius to get km)
Quick example
For New York and Washington, D.C. (central angle c ≈ 0.051552 rad)
distance \(d\) \(=\) equatorial radius (3963.15 mi) \(\times\) \(\bigl(\) central angle (0.051552 rad) \(-\) flattening correction (about 0.0000386) \(\bigr)\)
\(X \approx 0.0000093, \quad Y \approx 0.023014, \quad \frac{f(X + Y)}{2} \approx 0.0000386\)
\(d = 3963.15 \times (0.051552 - 0.0000386) \approx 204.2 \ \mathrm{mi} \quad (204.2 \times 1.60935 \approx 328.6 \ \mathrm{km})\)
Key idea
The base is the arc length rule for a sector: arc length = radius × central angle (in radians). \(3963.15 \times c\) alone is the arc length on a sphere with the equatorial radius, which is about 204.3 miles from New York to Washington, D.C. The term \(\dfrac{f(X+Y)}{2}\) then corrects for the flattened shape (here it shortens the distance by about 0.15 miles, or about 800 feet, to 204.2 miles). To get the answer in km, use the equatorial radius 6378.1 km in place of 3963.15 mi. The exact definitions of the in-between values \(X\) and \(Y\) are \(X = \dfrac{(c - \sin c)\sin^2 P \cos^2 Q}{\cos^2(c/2)}\) and \(Y = \dfrac{(c + \sin c)\sin^2 Q \cos^2 P}{\sin^2(c/2)}\), where \(P = \dfrac{U_1 + U_2}{2}\) and \(Q = \dfrac{U_2 - U_1}{2}\). They look complicated, but all of them are calculated step by step from the reduced latitudes and the central angle found in the first formula. The error of Lambert's formula is said to be about 10 meters (about 30 feet) even over distances of thousands of miles.
Converting DMS to decimal degrees
Standard notation (the usual math form)
\(D\) \(=\) \(d\) \(+\) \(\frac{m}{60}\) \(+\) \(\frac{s}{3600}\)
In words (symbols replaced with words)
④ \(D\): angle in decimal degrees \(=\) ① \(d\): degrees \(+\) ② minutes \(m \div 60\) \(+\) ③ seconds \(s \div 3600\)
The formula in words
① To the degrees \(d\)
② add the minutes \(m\) divided by 60
③ and the seconds \(s\) divided by 3600
④ and you get the angle in decimal degrees \(D\) (for south latitudes and west longitudes, put a minus sign in front at the end)
Quick example
The latitude of Washington, D.C., 38°53′51.36″ N, in decimal degrees is
angle in decimal degrees \(D\) \(=\) degrees (38) \(+\) minutes (53) ÷ 60 \(+\) seconds (51.36) ÷ 3600
\(38 + \frac{53}{60} + \frac{51.36}{3600} = 38 + 0.883333\ldots + 0.014266\ldots \approx 38.8976\)
Key idea
Degrees, minutes and seconds count in base 60, just like hours, minutes and seconds of time. 1 degree = 60 minutes and 1 minute = 60 seconds (so 1 degree = 3600 seconds). That is why you divide minutes by 60 and seconds by 3600 to turn them into degrees. For south latitudes and west longitudes, put a minus sign in front of the whole converted value (for example, 77°2′11.76″ W → −77.0366°). In decimal form, enter this negative value in the calculator. In DMS form, choosing "S" or "W" from the drop-down does the same thing.
Lambert's formula finds the distance between two latitude and longitude points in three moves - treat the Earth as a slightly flattened ellipsoid, find the central angle between the two points, and apply "arc length = radius × central angle" with a correction for the flattening. DMS counts in base 60 like time, so minutes ÷ 60 and seconds ÷ 3600 turn it into decimal degrees.

Symbols and terms

Symbols

\(\varphi\) phi Latitude: the angle that tells how far north or south of the equator (0°) a place is. North is positive and south is negative (−90° to 90°).
\(\lambda\) lambda Longitude: the angle that gives the east-west position, measured from the prime meridian (0°) through the old Royal Observatory in Greenwich, England. East is positive and west is negative (−180° to 180°).
\(f\) eff The flattening of the Earth: how squashed the ellipsoid is, as a ratio. This calculation uses \(f = \dfrac{1}{298.257}\).
\(U\) you The reduced latitude: the latitude on the ellipsoid converted with \(U = \arctan((1-f)\tan\varphi)\) so that it can be used in formulas for a sphere.
\(c\) see The central angle: the angle between the two points as seen from the center of the Earth (in radians). Through "arc length = radius × central angle", it is the base of the distance.
\(X\), \(Y\) ex, why In-between values used to correct for the flattened shape. They are calculated from the central angle \(c\), the average of the reduced latitudes \(P = \dfrac{U_1+U_2}{2}\) and half their difference \(Q = \dfrac{U_2-U_1}{2}\).
\(d\) dee The distance between the two points, from the first letter of "distance". This page shows it in miles and km (kilometers).
° ′ ″ degree, minute, second The symbols for degrees, minutes and seconds of angle. 1° = 60′ and 1′ = 60″. Example - 40°42′46.08″ (40 degrees, 42 minutes, 46.08 seconds).

Terms

latitude The angle that gives the north-south position, with the equator at 0°. The North Pole is 90° N and the South Pole is 90° S. It is a basic idea of maps and location data, taught in elementary and middle school geography.
longitude The angle that gives the east-west position, with the prime meridian (the line through Greenwich, England) at 0°. It goes up to 180° east and 180° west. The contiguous US lies between about 67° W and 125° W.
DMS A way of writing angles in base 60 with degrees, minutes and seconds. 1 degree = 60 minutes and 1 minute = 60 seconds. It is common on USGS topographic maps, nautical charts and GPS devices.
ellipsoid Here, an ellipsoid of revolution - the solid you get by spinning an ellipse around its axis. The Earth's rotation makes it bulge at the equator, so it is modeled as an ellipsoid rather than a sphere.
flattening The ratio that shows how squashed an ellipsoid is, defined as (equatorial radius − polar radius) ÷ equatorial radius. For the Earth it is about 1/300.
reduced latitude The latitude of a point on the ellipsoid after it is moved onto the helper circle (sphere) the ellipse is based on. It is found with \(U = \arctan((1-f)\tan\varphi)\) and is used in geodesy (the science of measuring the Earth's shape). It is also called the parametric latitude.
central angle The angle between two points as seen from the center of a circle or sphere. The sector rule "arc length = radius × central angle (in radians)" is the base of the distance calculation on this page.
geodesic The shortest path between two points on a curved surface. On the Earth it is close to the great-circle route, and airline routes follow roughly this shape. This page finds the approximate length along the geodesic.
haversine formula A well-known formula for the distance between two points that treats the Earth as a perfect sphere. Lambert's formula on this page is an improved version for the ellipsoid, and it uses a haversine-type formula for the central angle in the first step.
Lambert's formula A method for the distance between two points that models the Earth as an ellipsoid. Its error is said to be about 10 meters (about 30 feet) even over thousands of miles, which is more accurate than treating the Earth as a sphere.
mile A unit of distance used mainly in the US and the UK (the statute mile). 1 mile = 5,280 feet ≈ 1.609 km (exactly 1.609344 km by the international definition). This calculator converts with 1 mile = 1.60935 km. It is a different unit from the nautical mile below.
nautical mile A unit of distance used at sea and in aviation. 1 nautical mile = 1.852 km (about 1.15 miles or 6,076 feet). It was chosen to be about the length of 1 minute (1/60 of a degree) of latitude.

Good to know before you start

Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.
To just find a distance, knowing how to read latitude and longitude is enough. To understand what is inside the formulas, go back as far as trigonometric ratios and radians.

Latitude and longitude (Grades 4–6 social studies)
  • Knowing that latitude is the angle north or south of the equator, and longitude is the angle east or west of the prime meridian
  • Being able to tell N from S and E from W (the contiguous US lies between about 25° N and 49° N, and between about 67° W and 125° W)
Angles and base 60 (Grades 3–4 time, Grade 4 angles)
  • Knowing the base-60 rule 1 degree = 60 minutes and 1 minute = 60 seconds, the same as for time
  • Being able to turn minutes and seconds into decimal degrees, as in "30 minutes is 0.5 degrees"
Arc length of a sector (Geometry)
  • Knowing that arc length is proportional to the radius and the central angle (the base of "radius × central angle" in formula 2)
Trigonometric ratios sin, cos and tan (Geometry and Algebra 2)
  • Knowing that sin, cos and tan are values determined by an angle (only needed to understand the formulas; not needed just to use the calculator)
Radians (Algebra 2 and Precalculus)
  • Knowing radians as another unit of angle: on a circle of radius 1, the arc length is the angle itself. "Arc length = radius × central angle" works only when the angle is in radians
The shape of the Earth (middle school Earth science)
  • Knowing that the Earth is not a perfect sphere but an ellipsoid that bulges slightly at the equator because of its rotation

How to calculate it in Excel

Copy the whole table below and paste it into cell A1 in Excel. It works as is.
Table to convert DMS to decimal degrees
Degrees 38
Minutes 53
Seconds 51.36
Decimal degrees (add − for S and W) =B1+B2/60+B3/3600
Table to find the distance with Lambert's formula
Point 1 latitude (decimal; S is −) 40.7128
Point 1 longitude (decimal; W is −) -74.0060
Point 2 latitude 38.8976
Point 2 longitude -77.0366
Flattening f =1/298.257
Reduced latitude U1 =ATAN((1-B5)*TAN(RADIANS(B1)))
Reduced latitude U2 =ATAN((1-B5)*TAN(RADIANS(B3)))
Longitude difference Δλ (radians) =RADIANS(B4-B2)
Haversine term a =SIN((B7-B6)/2)^2+COS(B6)*COS(B7)*SIN(B8/2)^2
Central angle c (radians) =2*ATAN2(SQRT(1-B9),SQRT(B9))
Average P =(B6+B7)/2
Half difference Q =(B7-B6)/2
Correction value X =(B10-SIN(B10))*SIN(B11)^2*COS(B12)^2/COS(B10/2)^2
Correction value Y =(B10+SIN(B10))*SIN(B12)^2*COS(B11)^2/SIN(B10/2)^2
Distance (miles) =6378.1/1.60935*(B10-B5*(B13+B14)/2)
Distance (km) =B15*1.60935
The first table converts DMS to decimal degrees. B4 shows 38.8976.
The second table is every step of Lambert's formula. B1 to B4 are the inputs (decimal degrees), B6 onward are the in-between values of formulas 1 and 2, B15 is the distance in miles (about 204.15), and B16 is the distance in km (about 328.56). The calculator on this page rounds these to 204.2 mi and 328.6 km.
RADIANS(…) converts degrees to radians. In Excel, ATAN2(x, y) takes its arguments in the order (x-coordinate, y-coordinate), so note that c is written as 2×ATAN2(√(1−a), √a). 6378.1/1.60935 is the equatorial radius in miles (about 3963.15).

How to calculate it in Google Sheets

Copy the whole table below and paste it into cell A1 in Google Sheets. It works as is.
Table to convert DMS to decimal degrees
Degrees 38
Minutes 53
Seconds 51.36
Decimal degrees (add − for S and W) =B1+B2/60+B3/3600
Table to find the distance with Lambert's formula
Point 1 latitude (decimal; S is −) 40.7128
Point 1 longitude (decimal; W is −) -74.0060
Point 2 latitude 38.8976
Point 2 longitude -77.0366
Flattening f =1/298.257
Reduced latitude U1 =ATAN((1-B5)*TAN(RADIANS(B1)))
Reduced latitude U2 =ATAN((1-B5)*TAN(RADIANS(B3)))
Longitude difference Δλ (radians) =RADIANS(B4-B2)
Haversine term a =SIN((B7-B6)/2)^2+COS(B6)*COS(B7)*SIN(B8/2)^2
Central angle c (radians) =2*ATAN2(SQRT(1-B9),SQRT(B9))
Average P =(B6+B7)/2
Half difference Q =(B7-B6)/2
Correction value X =(B10-SIN(B10))*SIN(B11)^2*COS(B12)^2/COS(B10/2)^2
Correction value Y =(B10+SIN(B10))*SIN(B12)^2*COS(B11)^2/SIN(B10/2)^2
Distance (miles) =6378.1/1.60935*(B10-B5*(B13+B14)/2)
Distance (km) =B15*1.60935
The same formulas as in Excel (RADIANS, ATAN2, SQRT and so on) work as is in Google Sheets. Copy the whole table, paste it into cell A1, and replace B1 to B4 with your own latitudes and longitudes.

How to calculate it in Python

import math

# Latitude and longitude of the two points (decimal degrees; south and west are negative)
lat1, lon1 = 40.7128, -74.0060   # point 1 (near New York City Hall)
lat2, lon2 = 38.8976, -77.0366   # point 2 (near the White House, Washington, D.C.)

flattening = 1 / 298.257         # flattening of the Earth, f
equator_radius_km = 6378.1       # equatorial radius in km
equator_radius_mi = equator_radius_km / 1.60935   # equatorial radius in miles (about 3963.15)

# Formula 1, first half: reduced latitudes (latitudes shrunk by the flattening)
u1 = math.atan((1 - flattening) * math.tan(math.radians(lat1)))
u2 = math.atan((1 - flattening) * math.tan(math.radians(lat2)))
delta_lon = math.radians(lon2 - lon1)

# Formula 1, second half: central angle c between the two points (haversine-type formula)
a = math.sin((u2 - u1) / 2) ** 2 + math.cos(u1) * math.cos(u2) * math.sin(delta_lon / 2) ** 2
central_angle = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))

# Formula 2: correction for the flattened shape (X and Y), then the distance
p = (u1 + u2) / 2
q = (u2 - u1) / 2
x = (central_angle - math.sin(central_angle)) * math.sin(p) ** 2 * math.cos(q) ** 2 / math.cos(central_angle / 2) ** 2
y = (central_angle + math.sin(central_angle)) * math.sin(q) ** 2 * math.cos(p) ** 2 / math.sin(central_angle / 2) ** 2

distance_mi = equator_radius_mi * (central_angle - flattening * (x + y) / 2)
distance_km = distance_mi * 1.60935

print(f"Distance between the two points: {distance_mi:.1f} miles ({distance_km:.1f} km)")
Runs with the standard library only. Change the latitudes and longitudes at the top and run it (convert DMS to decimal first with "degrees + minutes ÷ 60 + seconds ÷ 3600"). If you enter exactly the same coordinates for both points, it divides by 0 and stops with an error.

How to write it in LaTeX and other math languages (copy and paste)

Central angle \(c\) between the two points (Lambert's formula, part 1)
U₁ = atan((1 − f)·tanφ₁), U₂ = atan((1 − f)·tanφ₂), c = 2·asin(√(sin²((U₂ − U₁)/2) + cosU₁·cosU₂·sin²((λ₂ − λ₁)/2)))
U_1 = \arctan\bigl((1-f)\tan\varphi_1\bigr),\ U_2 = \arctan\bigl((1-f)\tan\varphi_2\bigr),\quad c = 2\arcsin\sqrt{\sin^2\frac{U_2-U_1}{2} + \cos U_1 \cos U_2 \sin^2\frac{\lambda_2-\lambda_1}{2}}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <msub><mi>U</mi><mi>i</mi></msub>
    <mo>=</mo>
    <mi>arctan</mi>
    <mo>&#x2061;</mo>
    <mrow>
      <mo>(</mo>
      <mrow><mo>(</mo><mn>1</mn><mo>&#x2212;</mo><mi>f</mi><mo>)</mo></mrow>
      <mi>tan</mi><mo>&#x2061;</mo><msub><mi>&#x3C6;</mi><mi>i</mi></msub>
      <mo>)</mo>
    </mrow>
    <mo>,</mo>
    <mspace width="1em"/>
    <mi>c</mi>
    <mo>=</mo>
    <mn>2</mn>
    <mi>arcsin</mi>
    <mo>&#x2061;</mo>
    <msqrt>
      <mrow>
        <msup><mi>sin</mi><mn>2</mn></msup>
        <mo>&#x2061;</mo>
        <mfrac>
          <mrow><msub><mi>U</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>U</mi><mn>1</mn></msub></mrow>
          <mn>2</mn>
        </mfrac>
        <mo>+</mo>
        <mi>cos</mi><mo>&#x2061;</mo><msub><mi>U</mi><mn>1</mn></msub>
        <mi>cos</mi><mo>&#x2061;</mo><msub><mi>U</mi><mn>2</mn></msub>
        <msup><mi>sin</mi><mn>2</mn></msup>
        <mo>&#x2061;</mo>
        <mfrac>
          <mrow><msub><mi>&#x3BB;</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>&#x3BB;</mi><mn>1</mn></msub></mrow>
          <mn>2</mn>
        </mfrac>
      </mrow>
    </msqrt>
  </mrow>
</math>
U_1 = arctan((1-f) tan(varphi_1)), U_2 = arctan((1-f) tan(varphi_2)), c = 2 arcsin(sqrt(sin^2((U_2-U_1)/2) + cos(U_1) cos(U_2) sin^2((lambda_2-lambda_1)/2)))
u1 = ArcTan[(1 - f) Tan[phi1]]; u2 = ArcTan[(1 - f) Tan[phi2]]; c = 2 ArcSin[Sqrt[Sin[(u2 - u1)/2]^2 + Cos[u1] Cos[u2] Sin[(lambda2 - lambda1)/2]^2]]
U1 := arctan((1 - f)*tan(phi1)); U2 := arctan((1 - f)*tan(phi2)); c := 2*arcsin(sqrt(sin((U2 - U1)/2)^2 + cos(U1)*cos(U2)*sin((lambda2 - lambda1)/2)^2));
u1 = atan((1 - f)*tan(phi1)); u2 = atan((1 - f)*tan(phi2)); c = 2*asin(sqrt(sin((u2 - u1)/2)^2 + cos(u1)*cos(u2)*sin((lambda2 - lambda1)/2)^2));
U_1 = atan((1 - f) tan(φ_1)), U_2 = atan((1 - f) tan(φ_2)), c = 2 asin(√(sin^2((U_2 - U_1)/2) + cos(U_1) cos(U_2) sin^2((λ_2 - λ_1)/2)))
Correction for the ellipsoid and the distance \(d\) (Lambert's formula, part 2)
d = 3963.15·(c − f·(X + Y)/2), X = (c − sin c)·sin²P·cos²Q ÷ cos²(c/2), Y = (c + sin c)·sin²Q·cos²P ÷ sin²(c/2), P = (U₁ + U₂)/2, Q = (U₂ − U₁)/2
d = 3963.15\left(c - \frac{f(X + Y)}{2}\right),\quad X = \frac{(c - \sin c)\sin^2 P \cos^2 Q}{\cos^2(c/2)},\quad Y = \frac{(c + \sin c)\sin^2 Q \cos^2 P}{\sin^2(c/2)},\quad P = \frac{U_1 + U_2}{2},\ Q = \frac{U_2 - U_1}{2}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>d</mi>
    <mo>=</mo>
    <mn>3963.15</mn>
    <mrow>
      <mo>(</mo>
      <mi>c</mi>
      <mo>&#x2212;</mo>
      <mfrac>
        <mrow><mi>f</mi><mo>(</mo><mi>X</mi><mo>+</mo><mi>Y</mi><mo>)</mo></mrow>
        <mn>2</mn>
      </mfrac>
      <mo>)</mo>
    </mrow>
    <mo>,</mo>
    <mspace width="1em"/>
    <mi>X</mi>
    <mo>=</mo>
    <mfrac>
      <mrow>
        <mo>(</mo><mi>c</mi><mo>&#x2212;</mo><mi>sin</mi><mo>&#x2061;</mo><mi>c</mi><mo>)</mo>
        <msup><mi>sin</mi><mn>2</mn></msup><mo>&#x2061;</mo><mi>P</mi>
        <msup><mi>cos</mi><mn>2</mn></msup><mo>&#x2061;</mo><mi>Q</mi>
      </mrow>
      <mrow><msup><mi>cos</mi><mn>2</mn></msup><mo>&#x2061;</mo><mrow><mo>(</mo><mi>c</mi><mo>/</mo><mn>2</mn><mo>)</mo></mrow></mrow>
    </mfrac>
    <mo>,</mo>
    <mspace width="1em"/>
    <mi>Y</mi>
    <mo>=</mo>
    <mfrac>
      <mrow>
        <mo>(</mo><mi>c</mi><mo>+</mo><mi>sin</mi><mo>&#x2061;</mo><mi>c</mi><mo>)</mo>
        <msup><mi>sin</mi><mn>2</mn></msup><mo>&#x2061;</mo><mi>Q</mi>
        <msup><mi>cos</mi><mn>2</mn></msup><mo>&#x2061;</mo><mi>P</mi>
      </mrow>
      <mrow><msup><mi>sin</mi><mn>2</mn></msup><mo>&#x2061;</mo><mrow><mo>(</mo><mi>c</mi><mo>/</mo><mn>2</mn><mo>)</mo></mrow></mrow>
    </mfrac>
    <mo>,</mo>
    <mspace width="1em"/>
    <mi>P</mi>
    <mo>=</mo>
    <mfrac><mrow><msub><mi>U</mi><mn>1</mn></msub><mo>+</mo><msub><mi>U</mi><mn>2</mn></msub></mrow><mn>2</mn></mfrac>
    <mo>,</mo>
    <mi>Q</mi>
    <mo>=</mo>
    <mfrac><mrow><msub><mi>U</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>U</mi><mn>1</mn></msub></mrow><mn>2</mn></mfrac>
  </mrow>
</math>
d = 3963.15 (c - f(X + Y)/2), X = ((c - sin c) sin^2(P) cos^2(Q))/(cos^2(c/2)), Y = ((c + sin c) sin^2(Q) cos^2(P))/(sin^2(c/2)), P = (U_1 + U_2)/2, Q = (U_2 - U_1)/2
p = (u1 + u2)/2; q = (u2 - u1)/2; x = (c - Sin[c]) Sin[p]^2 Cos[q]^2/Cos[c/2]^2; y = (c + Sin[c]) Sin[q]^2 Cos[p]^2/Sin[c/2]^2; d = 3963.15 (c - f (x + y)/2)
P := (U1 + U2)/2; Q := (U2 - U1)/2; X := (c - sin(c))*sin(P)^2*cos(Q)^2/cos(c/2)^2; Y := (c + sin(c))*sin(Q)^2*cos(P)^2/sin(c/2)^2; d := 3963.15*(c - f*(X + Y)/2);
p = (u1 + u2)/2; q = (u2 - u1)/2; x = (c - sin(c))*sin(p)^2*cos(q)^2/cos(c/2)^2; y = (c + sin(c))*sin(q)^2*cos(p)^2/sin(c/2)^2; d = 3963.15*(c - f*(x + y)/2);
d = 3963.15(c - f(X + Y)/2), X = (c - sin c) sin^2(P) cos^2(Q)/cos^2(c/2), Y = (c + sin c) sin^2(Q) cos^2(P)/sin^2(c/2), P = (U_1 + U_2)/2, Q = (U_2 - U_1)/2
Converting DMS to decimal degrees
D = d + m/60 + s/3600
D = d + \frac{m}{60} + \frac{s}{3600}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>D</mi>
    <mo>=</mo>
    <mi>d</mi>
    <mo>+</mo>
    <mfrac><mi>m</mi><mn>60</mn></mfrac>
    <mo>+</mo>
    <mfrac><mi>s</mi><mn>3600</mn></mfrac>
  </mrow>
</math>
D = d + m/60 + s/3600
d + m/60 + s/3600
deg := d + m/60 + s/3600;  # D (the differential operator) is reserved in Maple, so the decimal degrees are named deg
D = d + m/60 + s/3600;
D = d + m/60 + s/3600

How to have ChatGPT  do the calculation

You are a geography calculation assistant. Do the following calculation by actually running Python code, and base your answer only on the numbers from the execution result (do not answer by mental math or guessing).

Find the distance between two points from their latitudes and longitudes using Lambert's formula, which models the Earth as an ellipsoid with flattening f = 1/298.257.
Steps: convert each latitude to the reduced latitude U = atan((1-f)·tanφ); a = sin²((U2-U1)/2) + cosU1·cosU2·sin²((λ2-λ1)/2); central angle c = 2·atan2(√a, √(1-a)); P = (U1+U2)/2; Q = (U2-U1)/2; X = (c-sin c)·sin²P·cos²Q/cos²(c/2); Y = (c+sin c)·sin²Q·cos²P/sin²(c/2); distance (km) = 6378.1·(c - f·(X+Y)/2).

Point 1: 40.7128° N, 74.0060° W (near New York City Hall)
Point 2: 38.8976° N, 77.0366° W (near the White House, Washington, D.C.)

Give the distance in miles and km (1 mile = 1.60935 km), and show the code you used and the numbers from the execution result.

How to Use
  1. 1
    Enter your numbers
    Type the numbers you want to calculate with into the input fields
  2. 2
    Calculate
    Press the "Calculate" button
  3. 3
    Check the result
    The result appears on the spot. The same page also explains the idea behind the calculation and the formula
  DataChef Features
Easy and Free
Unlimited conversions for free.
No technical knowledge required.
Intuitive and user-friendly operation.
No Registration Required
Available immediately after access.
Can be used without registering personal information.
Safe and Secure
Fully SSL encrypted communication.
Automatic file deletion by clicking "download".
Fast
High-speed site access
and rapid file conversion.
No Watermark
No watermark.
No attribution required.
Commercial Use Available
Free for commercial use.
No need to contact us for commercial use permission.