Weather Observation Station 18

  • + 2 comments

    Manhattan Distance

    The Manhattan distance, also known as taxicab distance or city block distance, is a metric used to measure the distance between two points in a grid-like structure (such as a city street grid), where you can only move horizontally or vertically (not diagonally).

    For two points P1(x1, y1) and P2(x2, y2), the Manhattan distance is calculated as the sum of the absolute differences of their coordinates:

    Manhattan Distance = |x2 - x1| + |y2 - y1|

    This formula gives you the Manhattan distance between two points in a grid system.

    Solution is Given Below

    MS SQL SERVER

    SELECT CAST(ROUND((ABS(MIN(LAT_N) - MAX(LAT_N)) + ABS(MIN(LONG_W) - MAX(LONG_W))), 4) AS DECIMAL(16,4))
    FROM STATION;
    

    Follow For More