Manhattan Distance
Author: Ernad Mujakic
Date: 2025-07-31
The Manhattan distance is a Distance Measure defined as the sum of the absolute differences of the Cartesian coordinates of two points. It is the distance between two points using only grid-like movements (horizontal and vertical). The Manhattan distance is also the
The Manhattan distance between two objects in
Properties
- Positive: Like any other distance metric, the range of the Manhattan distance is
where a 0 distance indicates that the two points are at the same location. - Symmetric: The Manhattan distance is symmetric, meaning
- Triangle Inequality: The Manhattan distance obeys the triangle inequality, which states that the distance from
to is always less than or equal to the distance from to plus the distance from to . Meaning that taking a detour through a third point cannot result in a shorter distance than a direct path from to .
Applications
- Clustering: Manhattan distance may be used in clustering algorithms like K-Means Clustering to group similar data points.
- Classification: The Manhattan distance may be employed in distance-based classification algorithms such as K-Nearest-Neighbors.
- Measuring Pixel Differences: The Manhattan distance, or other distance measures, may be employed to compare pixel values, or features in image recognition tasks.
Pathfinding
- The Manhattan distance can be used for calculating the shortest path between points. It is also an Admissible and Consistent Heuristic in search algorithms such as A* Search.
- Grid-Navigation: The Manhattan distance is particularly useful for pathfinding in domains which only allow grid-like movements, such as a chessboard or a city network.
Statistics
- Outlier Detection: Manhattan distance can be used for distance based outlier detection algorithms such as DBSCAN.
- Multidimensional Scaling: Manhattan distance may be employed to visualize higher-dimensional data into lower dimensions.
Other Distance Measures
Other common distance measures include:
- Euclidean Distance: The straight-line distance between 2 points in Euclidean space.
- Chebyshev Distance: The maximum absolute difference between 2 vectors across all dimensions.
- Minkowski Distance: A generalized distance measure that is defined by a parameter
whose common values are the Manhattan distance, Euclidean distance, and Chebyshev distance. - Jaccard Index: Used to compare sets and is defined as the size of the intersection of 2 sets, over the size of their union.
References
- J. Han and M. Kamber, Data Mining : Concepts and Techniques, 3rd ed. Haryana, India ; Burlington, Ma: Elsevier, 2018.
- “Taxicab geometry,” Wikipedia, Jan. 21, 2022. https://en.wikipedia.org/wiki/Taxicab_geometry
- GeeksforGeeks, “Clustering Distance Measures,” GeeksforGeeks, May 24, 2024. https://www.geeksforgeeks.org/machine-learning/clustering-distance-measures/#common-distance-measures (accessed Jul. 31, 2025).