Forum Discussion
How to Calculate Distance on map from one Postcode to Another Postcode
Hi Everyone,
Please provide advice/steps the most efficient way to calculate distance from Point A to Point B on Google map.
For example Postcode W1 (W1 is the postcode district in Central).. to W2... =10miles.
So taxi drivers can also calculate the distance covered by taxi.
Please find below link with the file with Postcode data From and To
https://ln2.sync.com/dl/990703150/t6mqmq23-ex9r6ht5-8wxhc4ex-gtnzn79y
Thank you.
Greg_Deckler Wow this is fantastic, let me have a good look at it tomorrow so I can accept the solution , I'll let you know, but definitely amazing...
18 Replies
- Greg_DecklerCommunity Champion
You will need something like the Google Maps API. https://www.youtube.com/watch?v=IGr5oQLm0ls
Not sure what your data looks like, just zip codes? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
- MYDATASTORYResolver I
I have two Postcodes columns | From {W2} To {W3} Greg_Deckler
- Greg_DecklerCommunity Champion
Right so your basic formula for short distances is:
dlon = lon2 - lon1
dlat = lat2 - lat1
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2( sqrt(a), sqrt(1-a) )
d = R * c (where R is the radius of the Earth)So you could do it (with lots of caveats in terms of the accuracy of the output of the above formula since the Earth isn't a perfect sphere) if you had the longitudes and latitudes of those zip codes.