Get Distance Between 2 Locations based on Coordinates in Python - Geographic Data #1

Learn to calculate the distance between two locations based on their latitude and longitude coordinates, either in decimal degrees (DD) or in decimals, minutes and seconds (DMS).

Better Everything
3 min readMay 5, 2023
Learn to calculate the distance between two locations based on their latitude and longitude coordinates, either in decimal degrees (DD) or in decimals, minutes and seconds (DMS).
Learn to calculate the distance between two locations based on their latitude and longitude coordinates, either in decimal degrees (DD) or in decimals, minutes and seconds (DMS). Image by brgfx on Freepik

Every place on the world has a latitude and longitude coordinate that together specify a location on Earth.

When you know the geographical coordinates of 2 locations, you can calculate the distance between them.

In this guide we will use Python to calculate the distance between 2 locations based on their coordinates.

Geographical coordinates can be specified in these 2 formats:

  • Decimal Degrees (DD)
    For example: Latitude 40.6892° & Longitude 74.0445°
  • Degrees, Minutes, Seconds (DMS)
    For example: Latitude 40°41’21.2892’’ N, & Longitude 74°2’40.2072’’ W

Converting DMS Coordinates to Coordinates in Decimal Degrees

To calculate the distance between two locations, we will use coordinates in the Decimal Degrees notation.

--

--

Better Everything

✅Programming, Data & Business ✅Automation & Optimization ✅Knowledge & Inspiration