0

I have an xlsx file which has 200 restaurants and 1 warehouse location with their coordinates in latitude and longitude. I want to calculate the distance from the warehouse to the restaurants using R. And rank them from shortes to longes in km. example table:

title: resturants with location 
name           latitude           longitude 
resturant1     23.646466          90.656566     
resturant2     23.786464          90.254577
resturant3     23.586464          90.789646
resturant4     23.452166          90.656989
x
x
200.....      ..........          .........

table2: warehouse location 
name          latitude             longitude 
warehouse     23.654654           90.7854555

from the above table, I want to calculate the distance from the warehouse to the restaurants using R. And rank them from shorts to longes in km.

Dave2e
  • 22,192
  • 18
  • 42
  • 50
  • You’ve flagged your question with driving-distance, so presumably that means you don’t want as the crow flies distances. So where are you getting your map data from? What constraints are you imposing on the road distances? (Eg are tolls allowed? What’s the size of the truck supplying the restaurants?). Please post your input data using dput(). – Limey Feb 21 '21 at 18:43
  • Please see the "geosphere" package, it contains a very handy function for performing this calculation. – Dave2e Feb 21 '21 at 18:46
  • 1
    Does this answer your question? [How to calculate Distance between two ZIPs?](https://stackoverflow.com/questions/52292765/how-to-calculate-distance-between-two-zips) – Dave2e Feb 21 '21 at 18:48
  • Here is a extensive discussion with solutions provided: – TarJae Feb 21 '21 at 18:50

0 Answers0