0

I have 2 datasets with three columns each. One has WarehouseID (primary key), WarehouseLat, and WarehouseLon. The other has StoreID (primary key), StoreLat, and StoreLon. The warehouses ship products to the stores. The goal is to determine which warehouse is closest to each store (by travel time or distance), in theory optimizing the distribution network. Ideally, the R package would not just use linear distances, but it would calculate travel time or distance over actual roads (in the USA).

I've looked at the stplanr package (https://cran.r-project.org/web/packages/stplanr/vignettes/stplanr-paper.html) but I don't believe this optimizes the combinations of 2 different types of entities (warehouses and stores). However, I am very elementary to R and I may be missing this functionality in the various packages I've found online.

The result of the script certainly doesn't have to appear this way, but this is essentially what I am envisioning: the resultant dataset would have 4 columns (StoreID (primary key), WarehouseID (foreign key), Distance, TravelTime). Again, it doesn't have to appear that way, but that would essentially answer the question I am trying to understand.

Chase
  • 544
  • 1
  • 11
  • 25
  • If you have Lat and Lon, maybe you will find ggmap interesting. Also, found this - https://cran.r-project.org/web/packages/gmapsdistance/gmapsdistance.pdf – denisafonin Jul 18 '19 at 15:18
  • Distance (as the crow flies) can be computed directly from coordinates. [This question](https://stackoverflow.com/q/31668163/903061) is a popular one for that. For travel time, [here's a question](https://stackoverflow.com/q/26496603/903061), the top result when I searched the R tag for "travel time". I'm going to close this question as a duplicate - of those as there's not really any new info here. If you have trouble implementing the solutions, edit your question to include some sample data and show what you tried, then we can re-open it. – Gregor Thomas Jul 18 '19 at 15:37
  • This might be of interest: https://www.movable-type.co.uk/scripts/latlong.html – rookie Jul 18 '19 at 15:54

0 Answers0