Finding the nearest zipcode from a list of zipcodes

Viewed 110

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

1 Answers

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.
Related