Skip to content
Omnikalc

Manhattan distance calculator: how far is it along a grid?

Enter two points in two or three dimensions to get the Manhattan, Euclidean and Chebyshev distances, and the Minkowski distance of any order.

Updated on
Your inputs

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

Results

Manhattan distance

19.000

Euclidean distance
13.000
Chebyshev distance
12.000
Minkowski distance of order p
12.207
Manhattan distance as a multiple of the straight line
1.462

On a grid of streets you cannot cut across the blocks, so the distance to travel is longer than the straight line. This Manhattan distance calculator takes the coordinates of two points and gives the Manhattan distance, the Euclidean distance, the Chebyshev distance, the Minkowski distance of order p and the ratio between the grid path and the straight line.

How the calculation works

  • Manhattan distance = |x₂ − x₁| + |y₂ − y₁| + |z₂ − z₁|. It is the length of a path that moves along the axes only, like a taxi on a grid of streets.
  • Euclidean distance = √(Δx² + Δy² + Δz²), the straight line between the two points.
  • Chebyshev distance = the largest of |Δx|, |Δy| and |Δz|, the number of moves of a chess king when each move can change every coordinate by one.
  • Minkowski distance of order p = (|Δx|^p + |Δy|^p + |Δz|^p)^(1/p). It is the Manhattan distance for p = 1, the Euclidean distance for p = 2 and approaches the Chebyshev distance as p grows.

Example

Take the points (1, 2, 3) and (4, 6, 15). The differences are 3, 4 and 12. The Manhattan distance is 3 + 4 + 12 = 19. The Euclidean distance is √(9 + 16 + 144) = √169 = 13, and the Chebyshev distance is 12. The Minkowski distance of order 3 is (27 + 64 + 1,728)^(1/3), about 12.2. The grid path is 19 ÷ 13 = 1.46 times longer than the straight line.

Why it matters

Data scientists compare vectors with the Manhattan distance, game developers use it to guess how far a unit must walk on a tile map, and planners use it to estimate a trip in a city laid out in blocks. Seeing it beside the Euclidean and Chebyshev distances shows how the choice of metric changes which points count as close.

Good to know

The calculator works for three coordinates and also for two when the z values are equal. It treats the axes as having the same scale, so mixed units, such as meters and seconds, should be rescaled first. The Manhattan distance depends on the orientation of the axes, unlike the Euclidean distance, so rotating a grid changes the result. Real streets are not a perfect grid, and a real route will be longer.

The distance formula calculator gives the straight line between two points and the point to line distance calculator finds the shortest distance to a line.

Frequently asked questions

What is the Manhattan distance?

The Manhattan distance, also called the taxicab or city block distance, is the sum of the absolute differences of the coordinates. It measures how far you travel when you can only move parallel to the axes, as in a city with a regular grid of streets. It is never shorter than the straight-line distance.

How do I use it for two dimensions?

Leave the z coordinates equal, for example both at zero, and the calculator gives the two-dimensional answer. The z difference is then zero and the formula reduces to |Δx| + |Δy|.

When is the Manhattan distance used?

It is used in grid-based path finding, in the A* search of games and robots, in image and signal comparison, in clustering and nearest neighbor methods, and in logistics for estimating delivery routes in cities. It is less sensitive to a single large difference than the Euclidean distance.

What is the Minkowski distance?

It is a family of distances controlled by the order p. For p = 1 you get the Manhattan distance, for p = 2 the Euclidean distance, and as p becomes very large the result approaches the Chebyshev distance, the largest single difference. Values of p below 1 are not distances in the strict sense, so the calculator starts at 1.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.