ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Distance between zip codes (https://www.excelbanter.com/excel-worksheet-functions/16961-distance-between-zip-codes.html)

Squid

Distance between zip codes
 
I need help constructing a formula to determine the distance between 2 zip
codes (actually the demical Lat & Lon). The zip code information was
downloaded from http://data.geocomm.com/editorspicks...ensuszips.html

I found the formula on this site: http://www.dbazine.com/weeg9.shtml

Column D: Decimal Longitude
Column E: Decmimal Latitude
Column F: DLON
Column G: DLAT
Column H: A
Column I: C
Column J: D


My excel equivlent formulas a
DLON = =ABS(D3-D2)
DLAT = =ABS(E3-E2)
A = SIN(G2/2)^2+COS(E2)*COS(E3)*SIN(F2/2)^2
C = 2*ASIN(MIN(1,SQRT(H2)))
D = 0.017453293*I2

But result is not correct. Anybody know what I did wrong?

TIA
Mike




Squid

http://www.cpearson.com/excel/latlong.htm

Forgot about the greatest excel help site on the web. Thanks Chip!

"Squid" wrote:

I need help constructing a formula to determine the distance between 2 zip
codes (actually the demical Lat & Lon). The zip code information was
downloaded from http://data.geocomm.com/editorspicks...ensuszips.html

I found the formula on this site: http://www.dbazine.com/weeg9.shtml

Column D: Decimal Longitude
Column E: Decmimal Latitude
Column F: DLON
Column G: DLAT
Column H: A
Column I: C
Column J: D


My excel equivlent formulas a
DLON = =ABS(D3-D2)
DLAT = =ABS(E3-E2)
A = SIN(G2/2)^2+COS(E2)*COS(E3)*SIN(F2/2)^2
C = 2*ASIN(MIN(1,SQRT(H2)))
D = 0.017453293*I2

But result is not correct. Anybody know what I did wrong?

TIA
Mike




Ron Rosenfeld

On Wed, 9 Mar 2005 16:57:08 -0800, "Squid"
wrote:

I need help constructing a formula to determine the distance between 2 zip
codes (actually the demical Lat & Lon). The zip code information was
downloaded from http://data.geocomm.com/editorspicks...ensuszips.html

I found the formula on this site: http://www.dbazine.com/weeg9.shtml

Column D: Decimal Longitude
Column E: Decmimal Latitude
Column F: DLON
Column G: DLAT
Column H: A
Column I: C
Column J: D


My excel equivlent formulas a
DLON = =ABS(D3-D2)
DLAT = =ABS(E3-E2)
A = SIN(G2/2)^2+COS(E2)*COS(E3)*SIN(F2/2)^2
C = 2*ASIN(MIN(1,SQRT(H2)))
D = 0.017453293*I2

But result is not correct. Anybody know what I did wrong?

TIA
Mike



Mike,

Excel's trig functions expect the angles to be in radians; you are inputting
them in degrees and not converting.

So for each reference to a lat/long, encase it in a RADIANS argument.

e.g. DLON = ABS(RADIANS(D3) - RADIANS (D2))



--ron


All times are GMT +1. The time now is 02:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com