[FoRK] zip code distance

Jeff Bone jbone at place.org
Wed Dec 23 04:38:42 PST 2009

Tangential to the freetable discussion (I'd *love* to have a  
centralized repo of various public data sources, normalized to a  
simple textual format;  I already download and do this for several for  
my own purposes, but would prefer not to be a curator of this sort of  
thing.  But I've amassed quite a list of such data sources;  Gordon,  
ping me off-list and I'll drop you a roundup of such things if useful.)

But --- re zip codes, I recently had a need to find the distance  
between (severals pairs of) two zip codes as a part of a little throw- 
away script I was writing.  Here's something that others might find  
useful.  It probably violates geocoder's terms-of-use and is DAMN slow  
and wasteful anyway (could easily be replaced by script that might  
take, oh, two minutes to write over any of a dozen public zip mapping  
databases out there that could be downloaded locally.  AT LEAST it  
should cache / memoize and deal with reflexivity.)  Usually works,  
doesn't actually *return* anything useful, could easily be improved in  
an infinite number of ways.  With those caveats and a stern admonition  
not to use this for any purpose, ever...  zipdist.


# Usage: zipdist zipcode1 [ zipcode2 ] --> distance in miles
# replace "78701" in the uri w/ your preferred default

function zipdist {
   local uri="http://geocoder.us/service/distance?zip1=${1}&zip2= 
   curl ${uri} 2>/dev/null |
     sed -e 's/.*=//' |
     sed -e 's/ miles$//'

zipdist $*


More information about the FoRK mailing list