NYCPHP Meetup

NYPHP.org

[nycphp-talk] Zip Code Stuff

Urb LeJeune urb at e-government.com
Mon Jan 22 10:52:06 EST 2007


         Thanks for the info, I'll check it out.

Urb


>You almost certainly want to use the Haversine formula for this task
>(calculating distances to points that are quite close on a sphere).
>
>http://en.wikipedia.org/wiki/Great-circle_distance
>
>The basic Great Circle formula gives *incorrect* results for points that are
>very close to each other.  I.E., the zip code 05702 is NOT actually on top
>of 05701, and I expect that your database of zip code centroids is fine,
>however, at some point roundoff error is killing you.  That is,
>
>arccos(1) = 0       //true!
>arccos(.999999999) = 0   //true for computers, not true for mathematicians
>
>So zip 05702 is too close to zip 05701, and its arccos is getting rounded to
>zero, which makes the distance calculated be zero, which is untrue.
>
>Use one of the other formulas on that Wikipedia page.







More information about the talk mailing list