开发者

Adding the distance between two zip codes to a data file

开发者 https://www.devze.com 2023-01-16 17:44 出处:网络
What is the best way to calculate AND add a field to a data file that shows the crow-fly distance (in miles) between two zip codes for each record (250K+) in a file?开发者_高级运维THANKSUse this page

What is the best way to calculate AND add a field to a data file that shows the crow-fly distance (in miles) between two zip codes for each record (250K+) in a file? 开发者_高级运维THANKS


Use this page for the raw distance information. Then use this website for the formula from Adam Bellaire's response to calculate the distance.

There is no reason to use an external service as zip codes really don't change all that often.

Enjoy!


Get a Google Earth API Key and use the API to calculate distances between two zip codes in your language of choice.

UPDATE:

If a web service isn't for you, you can check my OLD Visual Basic Posting on planet source code. It has a database of zip codes, their lat/long positions, and some VB code to calculate the distances between two zip codes. The Zipcode DB will probably require some updating, and it's in a MS Access format (but you can move that data anywhere).


You could use the Yahoo Geocoding Service to first get the latitude and longitude corrodinates for each zip code, then simply use the haversine formula to get the distance between any two sets of latitude/longitude data.

Here is a c# implementation of the haversine formula.

Enjoy!

0

精彩评论

暂无评论...
验证码 换一张
取 消