Giter Club home page Giter Club logo

zip-code-to-distance-calculator's Introduction

zip-code-to-distance-calculator

A simple python script which reads in a set of zip codes from one csv file (source addresses) and a set of zip codes from a second csv file (destination addresses) and computes a distance between each pair of source and destination zip codes. The output is written to an output csv file.

Currently, the distance calculation is the vincenty distance based on a mapping to the latitude and longtitude associated with each zip code.

Setup

All commands should be executed from directory root

(Optional) Setup Python 3 Virtualenv

  • Install python 3.x if not already installed
    • Code tested with 3.8; but presumably any Python 3 version should work
  • Install pip if not already installed (should be part of python install)
  • Install virtualenv if desired for environment isolation
  • Create & activate virtualenv:
    virtualenv -p python3 venv
    source venv/bin/activate
    

Install dependencies

pip install -r requirements.txt

Format input files

You will need 2 csv files both w/ the same format. One w/ the source addresses and the other with destination addresses. Each file should have a header row with a column named Zip Code:

Zip Code,Zip Code Name,State
10552,Mount Vernon, NY

Two sample files (sample_address_file_a.csv and sample_address_file_b.csv) are provided for testing.

Run script

Sample command

python compute_distances.py --src sample_address_file_a.csv \
 --dst sample_address_file_b.csv \
 --outfile output_distances.csv

Running the above command should yield an output csv file at output_distances.csv with the following contents:

Source Zip Code,Destination Zip Code,Geodic Distance
10552,10550,1.131330300414714
10552,53013,740.3885268206351

Run python compute_distances.py --help for more parameter details/options.

zip-code-to-distance-calculator's People

Contributors

rchaks avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.