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

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,106 questions

1. 57,091 Reputation points
2022-12-28T22:10:56.787+00:00

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

2. 38,426 Reputation points Microsoft Employee
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.

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