how to find logitude/latitude of address & distance between 2 addresses

Posted on 2005-04-07
Last Modified: 2008-02-01
This is not exactly a VB question (only I'm using VB to write the program).
Does anyone have info about how to:
1. Find out what the coordinate (longitude/latitude) of an address in U.S. is and
2. Find the distance between 2 addresses.
Doesn't have to be free, desirable but not mandatory.
Thanks a whole bunch.
Question by:spoowiz
    LVL 12

    Expert Comment

    Here is some stuff on EE, if you haven't already seen it

    Here is some programmable mapping software, just not vb

    LVL 16

    Accepted Solution

    An approximate distance calculation is below (it doesn't account for curvature of the earth)

    Public Function CalcDistance(ByVal dblLat1 As Double, ByVal dblLg1 As Double, ByVal dblLat2 As Double, ByVal dblLg2 As Double, ByRef dblMiles As Double) As Boolean
    'this function calculates the approximate distance between to points on the globe, given
    'a starting point latitude/longitude and and ending point latitude/longitude/
    Dim dblDistLat As Double
    Dim dblDistLong As Double

    dblDistLat = 69.1 * (dblLat2 - dblLat1)
    dblDistLong = 69.1 * (dblLg2 - dblLg1) * Cos(dblLat1 / 57.3)
    dblMiles = ((dblDistLat ^ 2) + (dblDistLong ^ 2)) ^ 0.5

    CalcDistance = True
    End Function

    The exact calculation is
    Distance = 3959 arcCos(Sin(Lat1)Sin(Lat2) +cos(Lat1)cos(Lat2)(Cos(Long2-Long1))

    We buy a zip code database from, which provide Lat & Long.
    LVL 13

    Expert Comment

    >>1. Find out what the coordinate (longitude/latitude) of an address in U.S. is

    You will need to have a database of locations in U.S.....The database should have at least three fields if not more......

    1) Latitude
    2) Longitude
    3) Address Info (Locations)

    >>2. Find the distance between 2 addresses.

    Once you know the Lat/Long of two places then calculating  distance between them can be done using a simple equation......

    Distnace Between (long1,lat1) and (long2,lat2) = R * ACos[sin(lat1)*sin(lat2) + cos(lat1)*cos(lat2)*cos(long1-long2)]

    LVL 13

    Expert Comment

    Oh sorry I didnot noticed that JohnBPrice has already posted the formula......


    Author Comment

    Thank you for the formula and other who responded.

    For address coordinate, I found out the zip+4 only has about 4 homes so it's close enough for me.
    You can also get zipZ+4 files with coordinates at usps.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now