How to calculate the road distance between two cities using databricks?

Deepak Raj Lingadurai 1 Reputation point
2022-12-28T11:45:47.833+00:00

We need to calculate road distance between two cities in databricks.

  • The available datas are city name,State name.

Can we use azure maps to calculate it.

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,540 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Dillon Silzer 57,831 Reputation points Volunteer Moderator
    2022-12-28T22:10:56.787+00:00

    Hi @Deepak Raj Lingadurai

    You will want to combine two different types of steps (the examples are in Python so you should be using that language in Azure Databricks).

    1) You will want to get the longitude and latitude of the cities:

    How To Get Latitude & Longitude with python

    https://stackoverflow.com/questions/25888396/how-to-get-latitude-longitude-with-python

    There are a couple of answers (one using Google Maps API and some other alternatives using python requests library).

    2) You can use the longitude and latitude calculation to calculate the distance between two points:

    How can I quickly estimate the distance between two (latitude, longitude) points?

    https://stackoverflow.com/questions/15736995/how-can-i-quickly-estimate-the-distance-between-two-latitude-longitude-points

    If you have a mathematics background you can also take a look at the calculation for further understanding:

    https://en.wikipedia.org/wiki/Haversine_formula


    If this is helpful please accept answer.


  2. ShaikMaheer-MSFT 38,551 Reputation points Microsoft Employee Moderator
    2022-12-30T09:25:04.727+00:00

    Hi

    Thank you for posting query in Microsoft Q&A Platform.

    Databricks notebooks can execute python code, so you can make API calls to Azure Maps to get distance information using Python code from Databricks notebook.

    Below is documentation of one such Azure Maps API, which gives us Route direction details between origin and destination. You can think of using this API.
    https://learn.microsoft.com/en-us/rest/api/maps/route/get-route-directions?tabs=HTTP

    Regarding making API calls from python code there are so many resources available online, you can go through them.

    Hope this helps. Please let me know how it goes.

    -------------

    Please consider hitting Accept Answer button. Accepted answers help community as well.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.