Distance Zip Code Database

  • Hello,

    I am looking to find away to determine the distance between one Zip Code and another Zip Code in a database.  For example, I would like to determine how far Customer A is from Customer B based on each Customer's Zip Code.

    Can someone help me understand how this can be done?  I am guessing I would need to purchase some kind of Zip Code database which would have some kind of calculation query.

    Any recommendations, thoughts. feedback is sincerely appreciated.

  • you can poke around, but there is an open source zip code database here: you can easily find others.

    https://public.opendatasoft.com/explore/dataset/us-zip-code-latitude-and-longitude/table/

    https://gist.github.com/erichurst/7882666

    that has a latitude and longitude  for the center of each zip code.

    from there, it's a relatively simple formula, to calculate the distance between the two points. now the question is, do you want, say the approximate latitude/longitude of the web user, or just between two known zip codes? if it is the latter, it is faster to just calcualte the values and store them , i think.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Presumably you want the driving distance and not the "as the crow files" (straight linear) distance.  For that you will need a software package.  You will also need to get periodic updates, since driving distances can change.  Even flying distances can sometimes changes, as new airports are built and others are shut down.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply