Search
Code Directory
 ASP
 ASP.NET
 C/C++
 CFML
 CGI/PERL
 Delphi
 Development
 Flash
 HTML
 Java
 JavaScript
 Pascal
 PHP
 Python
 SQL
 Tools
 Visual Basic & VB.NET
 XML
New Code
White-label Grocery Delivery App Solution 2.0
Best Classified Script 5.1
Readymade B2B Script 1.3.1
Uber Clone with Safety Measure Addons 2.0
Equity Investing Software 1.3.2
C# QR Code Generator 2020.6.0.0
The .Net PDF Library 2020.7.1
dbExpress driver for MySQL 7.2
dbForge Documenter for Oracle 1.2
dbForge Studio for Oracle 4.2
Excel .Net Library 2020.6
fsMediaLibrary.NET 2019.11
VaxVoIP SIP Server SDK 5.2.0
Database Workbench Pro 5.7.4
dbForge Data Generator for Oracle 2.2
Top Code
phpEnter 5.1.
Single Leg MLM 1.2.1
Azizi search engine script PHP 4.1.10
Paste phpSoftPro 1.4.1
Extreme Injector 3.7
Deals and Discounts Website Script 1.0.2
Solid File System OS edition 5.1
Classified Ad Lister 1.0
Aglowsoft SQL Query Tools 8.2
Invoice Manager by PHPJabbers 3.0
ICPennyBid Penny Auction Script 4.0
PHP Review Script 1.0
ATN Resume Finder 2.0
ATN Site Builder 3.0
Availability Booking Calendar PHP 1.0
Report About Calculating the distance between zip codes
- required fields

Please enter text on the image
  



I came across the mention of a formula labeled "The Great Circle Distance Formula" that purported to calculate the distance between any two points on the earth given their longitude and latitude points (the reference was in a Linux Magazine article). So, I looked up some information and cooked up a Python version of the calculation. There are references in the code where you can obtain approximate zip code data for free (e.g., if you wanted to enhance your website by adding a "Search within x mi's" feature), as well as references to the GCDF if you have further interest. Enjoy!

04/25/2006 update: I've decided to update this recipe with an object oriented bent where the information is cached once the object is instantiated. I've also added command line access to automatically download the zipcode file from the census website (just use 'python zips.py -d' and it will download a copy to your harddrive under 'zips.txt'). Lastly, I've added some unit testing so that if any future changes are made this will automatically run and tell me if anything pops out as wrong.

Back