2

I have a list of locations with zipcodes. I have another list of Distribution Centers that serve these locations. Is there anyway to map the nearest DC to each of these locations? I am an extremely green coder, but i have some experience with R

  • maybe this could be useful https://stackoverflow.com/questions/17361909/determining-the-distance-between-two-zip-codes-alternatives-to-mapdist – desval May 13 '20 at 18:46
  • Welcome to StackOverflow! Could you please provide with a list of sample data so it can more helpful for other users? – Serhii Matrunchyk May 13 '20 at 19:14
  • There is an R package, "ZipRadius" that may help. Also the archived package "zipcode" can provide a list of lat/long for each zip code. – Dave2e May 13 '20 at 19:30

1 Answers1

0

I'd need more information to give you some possible code to solve your problem however, here is one approach to solving your problem.

  1. Convert your zipcodes to longitudes and latitudes.
  2. Not sure what location data you have on your distribution centers, but you should be able to find a way to retrieve the long/lat of each of these.
  3. For each zipcode, compute the the distance to each DC (using their respective longs/lats). To compute the distance, use the haversine formula. Find the minimum of these distances. This is your solution.
lmeninato
  • 462
  • 4
  • 12