Ho do I calculate distance based on zip code (stores within distance) 
Author Message
 Ho do I calculate distance based on zip code (stores within distance)

Hi,

I am trying to figure out how to determine the distance from any valid zip
code to another, then display result depending the distance found. For
example: Enter your zip code to find a store locations that are within
(combo box) 10miles. 50miles, 100miles etc. Then display the results. I am
using an access database and VBScript. I am hoping I could purchase a third
party utility/db that already has normalized tables that include the zip
code tables. Then I would simply need to add table or two for the data I
want displayed depending on the query result. If anyone could point me in
the right direction I would appreciate it very much.

Regards,

Sean



Fri, 13 Aug 2004 03:29:56 GMT  
 Ho do I calculate distance based on zip code (stores within distance)

Quote:

> Hi,

> I am trying to figure out how to determine the distance from any valid zip
> code to another, then display result depending the distance found. For
> example: Enter your zip code to find a store locations that are within
> (combo box) 10miles. 50miles, 100miles etc. Then display the results. I am
> using an access database and Vbscript. I am hoping I could purchase a third
> party utility/db that already has normalized tables that include the zip
> code tables. Then I would simply need to add table or two for the data I
> want displayed depending on the query result. If anyone could point me in
> the right direction I would appreciate it very much.

> Regards,

> Sean

I don't know about the US, but in the UK, you can get a database from
the Post Office containing all post codes (zip codes) and there
associated x,y co-ordinates on the national grid. I have in the past
used code to convert the x,y co-ordinates to latitudes and longitudes
and done a distance calculation based on the great circle method.

--
Hope this helps
Tony Oakley (MVP)



Fri, 13 Aug 2004 17:14:31 GMT  
 Ho do I calculate distance based on zip code (stores within distance)
I did a system in Access a while back. It didn't use zips it use the lng/lat
of exact addresses. However, I looked on the web and found some resources.

http://www.freegis.org/index.en.html
and
http://www.cryptnet.net/fsp/zipdy/

Jeff



Mon, 16 Aug 2004 04:35:39 GMT  
 Ho do I calculate distance based on zip code (stores within distance)
This code will calc the distance.  Just call the function with the latitudes
and longitudes.
'---------------------------------------------------------------------------
-----
Option Compare Database
Option Explicit
Public appXL As Object

Public Function XL_Acos(inValue As Double) As Double
    If appXL Is Nothing Then
        Set appXL = CreateObject("Excel.Application")
    End If
    If (Abs(inValue) > CDbl(1)) Then
        If inValue < 0 Then
            inValue = CDbl(-1)
        Else
            inValue = CDbl(-1)
        End If
    End If

    XL_Acos = appXL.Acos(inValue)
End Function

Public Function getDistance(la1 As Double, lo1 As Double, la2 As Double, lo2
As Double) As Single
    ' = (24856.84 miles / (2 * 3.1415926535897932) radians)
    '  miles per radian = (earths circumference / radians in a circle)
  Const DistanceMultiplier As Double = 3956.08895564435
  getDistance = XL_Acos((Sin(la1) * Sin(la2)) + (Cos(la1) * Cos(la2) *
Cos(lo1 - lo2))) _
                      * DistanceMultiplier
End Function
'---------------------------------------------------------------------------
-------



Mon, 16 Aug 2004 05:11:56 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Distance between zip codes

2. Need some help with Calculating distance

3. Calculate Distance Lat... Long

4. Calculating distance between 2 points.

5. Levenshtein distance

6. DISTANCE/BEARING COMPUTATIONS

7. Algorithm wanted: Editing Distance

8. Distance Learning Tutorial-Help!

9. long distance syncronisation

10. Multiple Syncronice on long distance

11. Gabor filters/Euclidean distance

12. lat/lond distance question

 

 
Powered by phpBB® Forum Software