Distance Calculator with Latitude and Longitude
Distance calculator with latitude and longitude for the great-circle distance and bearing between two places, plus 2D and 3D point distances.
Distance
- Δx
- 6
- Δy
- 8
- Midpoint
- (5, 7)
- Slope
- 1.333333333
How to use the Distance Calculator
- Choose 2D points, 3D points or Latitude / longitude.
- Enter the coordinates of the first point, then the second. Negative values are allowed.
- Read the distance as you type, with the formula used shown under it.
- Check the extra figures: the differences and midpoint for coordinates, or the distance in other units and the initial compass bearing for places on Earth.
Formula
d = √((x₂ − x₁)² + (y₂ − y₁)²)
Where:
- d
- Straight-line distance between the two points, in the same units as the coordinates
- x₁, y₁
- Coordinates of the first point
- x₂, y₂
- Coordinates of the second point
- x₂ − x₁, y₂ − y₁
- Horizontal and vertical differences (Δx and Δy), the legs of a right triangle whose hypotenuse is d
3D adds (z₂ − z₁)² under the root. For latitude and longitude the calculator uses the haversine formula on a sphere with the IUGG mean Earth radius of 6,371.0088 km; this is the straight path over the surface, not a road or flight route, and can differ from ellipsoidal (Vincenty) results by up to about 0.5%.
Worked example
On a city map with a 1 km grid, a delivery drone flies straight from point (−4, 1) to point (5, 13). The operator charges $0.80 per kilometer flown. How far does it fly, and what does the trip cost?
- Δx = 5 − (−4) = 9 km and Δy = 13 − 1 = 12 km.
- d = √(9² + 12²) = √(81 + 144) = √225 = 15 km.
- Cost = 15 × $0.80 = $12.00.
The drone flies 15 km in a straight line (about 9.32 miles), so the trip costs $12.00.
How to calculate the distance between two coordinates
For two places on Earth, choose Latitude / longitude and enter each as a pair of decimal degrees. The result is the great-circle distance, the shortest path over the surface of a sphere, often described as the distance as the crow flies. It is shown in kilometers, miles and nautical miles, with the initial compass bearing from the first place toward the second.
The method is the haversine formula. With latitudes φ and longitudes λ in radians,
a = sin²(Δφ ÷ 2) + cos φ₁ × cos φ₂ × sin²(Δλ ÷ 2), then d = 2R × asin(√a),
where R is the mean radius of the Earth, 6,371.0088 km. This form stays accurate for very short distances, where the older spherical law of cosines loses precision.
Worked example. Sydney is at about (−33.8688, 151.2093) and Melbourne at about (−37.8136, 144.9631). Both latitudes are negative because the cities are south of the equator.
- Great-circle distance: about 713.43 km, or 443.30 miles, or 385.22 nautical miles.
- Initial bearing from Sydney: about 230.3°, which is southwest.
The drive along the Hume Highway is roughly 870 to 880 km, about a fifth longer, because the road follows valleys and towns.
Entering latitude and longitude correctly
- Decimal degrees only. There are no degrees-minutes-seconds fields, so convert first: 40° 42′ 46″ N is 40 + 42 ÷ 60 + 46 ÷ 3,600 ≈ 40.7128.
- Signs carry the hemisphere. North and east are positive; south and west are negative. Latitude runs from −90 to 90 and longitude from −180 to 180.
- Latitude first. A swapped pair often lands in the ocean or on the wrong continent.
- Order matters for the bearing, not the distance. The bearing back from the second place is generally not the first bearing plus 180°, because a great circle crosses each line of longitude at a different angle.
Do not put raw latitudes and longitudes into the flat 2D mode. One degree of longitude spans about 111 km at the equator and shrinks to nothing at the poles.
How accurate is a great-circle distance?
The Earth is treated as a perfect sphere. It is really slightly flattened at the poles, so ellipsoidal methods used in surveying, such as Vincenty's formulae, can differ by up to about 0.5%. Elevation and terrain are ignored, and the figure is never a road, rail or flight-path distance.
A quick sanity check: one degree of latitude is about 111 km (69 miles, 60 nautical miles) anywhere on the globe. Two places 3° of latitude apart on the same meridian should come out near 334 km.
The distance formula for two points in 2D and 3D
The other two modes work on plain Cartesian coordinates: a graph in algebra class, a floor plan, a game map, a point in space.
- 2D: d = √((x₂ − x₁)² + (y₂ − y₁)²). The gaps Δx and Δy are the legs of a right triangle and the distance is its hypotenuse.
- 3D: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). Applying Pythagoras a second time adds one more squared term.
These coordinates carry no unit of their own: a grid in meters gives meters, a grid in feet gives feet. Keep both points in the same unit.
A storeroom is 5 m long, 4 m wide and 3 m high. The longest straight rod that fits runs from one bottom corner, (0, 0, 0), to the opposite top corner, (5, 4, 3): d = √(25 + 16 + 9) = √50 ≈ 7.07 m. The floor diagonal alone is √41 ≈ 6.40 m, so tilting the rod upward gains about 67 cm.
Two slips are common: forgetting the square root, which leaves the squared distance (100 instead of 10), and mishandling a negative, since 5 − (−4) is 9, not 1.
How to find the midpoint
The midpoint is the average of each coordinate, ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2), with a z-term in 3D. It is listed under every 2D and 3D result, so those modes double as a midpoint calculator; the 2D mode also shows Δx, Δy and the slope.
From (1.5, −2.25) to (−3.5, 4): Δx = −5 and Δy = 6.25. Squaring removes the signs: 25 + 39.0625 = 64.0625, and √64.0625 ≈ 8.0039. The midpoint is (−1, 0.875) and the slope is 6.25 ÷ −5 = −1.25. For the full equation of that line, use the slope calculator.
Assumptions
The 2D and 3D modes are exact apart from display rounding: calculations use 40 significant digits and results are shown to 10. The latitude and longitude mode uses a spherical Earth and returns no midpoint. For navigation, legal boundaries or survey work, use dedicated geodesic software. Travel time belongs to the speed calculator.
Frequently asked questions
How do I calculate the distance between two points with latitude and longitude?
Choose Latitude / longitude and enter each place in decimal degrees, using negative numbers for south and west. London (51.5074, −0.1278) to New York (40.7128, −74.006) is about 5,570 km or 3,461 miles on a spherical Earth. The result is the great-circle distance over the surface, with the initial compass bearing from the first place.
How do I calculate the distance between two points?
Subtract the x-coordinates and the y-coordinates, square both differences, add them and take the square root: d = √((x₂ − x₁)² + (y₂ − y₁)²). From (2, 3) to (8, 11) the differences are 6 and 8, so the distance is √100 = 10.
What is the distance formula between two points?
It is the Pythagorean theorem written in coordinates. The horizontal and vertical differences between the points are the two legs of a right triangle and the line between them is the hypotenuse, so d = √(Δx² + Δy²). In 3D a third term is added: from (1, 2, 3) to (4, 6, 15) the differences are 3, 4 and 12, and d = √169 = 13.
How do I find the midpoint of two coordinates?
Average the coordinates: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2). The midpoint of (2, 3) and (8, 11) is (5, 7). It is shown under the distance in the 2D and 3D modes, with a z-coordinate in 3D. The latitude / longitude mode gives a distance and bearing only, not a geographic midpoint.
How do I find the distance between two points on a graph?
Read off the coordinates of both points, then count the horizontal and vertical gaps between them. Those gaps are the legs of a right triangle. From (3, 2) to (7, 5) the gaps are 4 and 3, so the distance is √(16 + 9) = 5 grid units. Multiply by the scale if one square stands for more than one unit.
Why is the straight-line distance shorter than the driving distance?
The calculator measures the shortest path, often called “as the crow flies.” Roads bend around terrain, buildings and water, so driving distances are typically 20% to 40% longer, and flight routes also deviate for winds and air traffic. Treat the result as a lower limit for any real journey.
Related calculators
- Slope CalculatorSlope calculator: two points or a rise and run give the slope as a decimal and fraction, plus the angle, percent grade and line equation.
- Length ConverterUse this length converter: feet to meters, cm to inches, miles to km or any pair of nine units, with exact factors and every unit listed.
- Area CalculatorArea calculator: square feet, square meters or six other units for 12 shapes, from rectangles and circles to a triangle with three known sides.
- Perimeter CalculatorPerimeter calculator: circle circumference from the radius, plus the distance around rectangles, triangles, semicircles and eight other shapes.
- Scientific CalculatorA free online scientific calculator in degree mode by default, with a DEG/RAD switch, trig, logs, powers, roots, memory and history.
Last updated: