PC Review


Reply
Thread Tools Rate Thread

Distance Calculation

 
 
=?Utf-8?B?SlNwZW5jZTIwMDM=?=
Guest
Posts: n/a
 
      7th Aug 2007
I already have a VBA Script that calculates distances from lat/long of 2
points (a reference point, then other locations). This type of script is
widely available on the net.

My situation now is that I have a list of 7 locations (each with its own
lat/long). I want to find out how close they are to each other.

With my current script, the only way I can figure this out is to copy the
locations into 7 separate columns to run the script 7 times. That is fine
with a small #, but what about if I have 100 locations?

Any suggestions?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9obiBCdW5keQ==?=
Guest
Posts: n/a
 
      7th Aug 2007
Just build a loop to do it, I just today completed that very thing. If you
create a function that does your calculations and just send the numbers it is
very fast. Mine looks at the location of 300 drivers, compares their location
to the lat long I provided, gets the distance and finds the 6 closest, runs
in under 2 seconds. And this machine is junk. If you can build a function and
an array you are set. This is the function we use, i pass in the driver
lat/long and the location lat/long and it returns a result that I do a little
more math on
Public Function calcDistance(destLat, driverLat, destLong, driverLong)
calcDistance = Math.Sqr(((destLat - driverLat) ^ 2) + (destLong -
driverLong) ^ 2)
End Function
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"JSpence2003" wrote:

> I already have a VBA Script that calculates distances from lat/long of 2
> points (a reference point, then other locations). This type of script is
> widely available on the net.
>
> My situation now is that I have a list of 7 locations (each with its own
> lat/long). I want to find out how close they are to each other.
>
> With my current script, the only way I can figure this out is to copy the
> locations into 7 separate columns to run the script 7 times. That is fine
> with a small #, but what about if I have 100 locations?
>
> Any suggestions?

 
Reply With Quote
 
=?Utf-8?B?SlNwZW5jZTIwMDM=?=
Guest
Posts: n/a
 
      7th Aug 2007
That sounds like the script I already have. Where it will plot the distance
between 2 points given you have an origin point and a destination point.

The situation I have now is a list of 7 stores, I want to know how close
they are to each other.

e.g. (store 1 is 5 miles from store 2, 7 miles from store 3, etc)

Jason

"John Bundy" wrote:

> Just build a loop to do it, I just today completed that very thing. If you
> create a function that does your calculations and just send the numbers it is
> very fast. Mine looks at the location of 300 drivers, compares their location
> to the lat long I provided, gets the distance and finds the 6 closest, runs
> in under 2 seconds. And this machine is junk. If you can build a function and
> an array you are set. This is the function we use, i pass in the driver
> lat/long and the location lat/long and it returns a result that I do a little
> more math on
> Public Function calcDistance(destLat, driverLat, destLong, driverLong)
> calcDistance = Math.Sqr(((destLat - driverLat) ^ 2) + (destLong -
> driverLong) ^ 2)
> End Function
> --
> -John
> Please rate when your question is answered to help us and others know what
> is helpful.
>
>
> "JSpence2003" wrote:
>
> > I already have a VBA Script that calculates distances from lat/long of 2
> > points (a reference point, then other locations). This type of script is
> > widely available on the net.
> >
> > My situation now is that I have a list of 7 locations (each with its own
> > lat/long). I want to find out how close they are to each other.
> >
> > With my current script, the only way I can figure this out is to copy the
> > locations into 7 separate columns to run the script 7 times. That is fine
> > with a small #, but what about if I have 100 locations?
> >
> > Any suggestions?

 
Reply With Quote
 
=?Utf-8?B?Sm9obiBCdW5keQ==?=
Guest
Posts: n/a
 
      7th Aug 2007
Sounds like you are on the right path if you are feeding the information into
an array, if you're not, it will take a LOT longer. What steps are you
needing help with from here or were you just seeing if there was a better way?
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"JSpence2003" wrote:

> That sounds like the script I already have. Where it will plot the distance
> between 2 points given you have an origin point and a destination point.
>
> The situation I have now is a list of 7 stores, I want to know how close
> they are to each other.
>
> e.g. (store 1 is 5 miles from store 2, 7 miles from store 3, etc)
>
> Jason
>
> "John Bundy" wrote:
>
> > Just build a loop to do it, I just today completed that very thing. If you
> > create a function that does your calculations and just send the numbers it is
> > very fast. Mine looks at the location of 300 drivers, compares their location
> > to the lat long I provided, gets the distance and finds the 6 closest, runs
> > in under 2 seconds. And this machine is junk. If you can build a function and
> > an array you are set. This is the function we use, i pass in the driver
> > lat/long and the location lat/long and it returns a result that I do a little
> > more math on
> > Public Function calcDistance(destLat, driverLat, destLong, driverLong)
> > calcDistance = Math.Sqr(((destLat - driverLat) ^ 2) + (destLong -
> > driverLong) ^ 2)
> > End Function
> > --
> > -John
> > Please rate when your question is answered to help us and others know what
> > is helpful.
> >
> >
> > "JSpence2003" wrote:
> >
> > > I already have a VBA Script that calculates distances from lat/long of 2
> > > points (a reference point, then other locations). This type of script is
> > > widely available on the net.
> > >
> > > My situation now is that I have a list of 7 locations (each with its own
> > > lat/long). I want to find out how close they are to each other.
> > >
> > > With my current script, the only way I can figure this out is to copy the
> > > locations into 7 separate columns to run the script 7 times. That is fine
> > > with a small #, but what about if I have 100 locations?
> > >
> > > Any suggestions?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
UK postcode distance calculation? Steve Hawkins Microsoft Excel Discussion 9 6th Apr 2006 01:27 PM
Distance/Time calculation =?Utf-8?B?UkM=?= Microsoft Excel Programming 1 2nd Feb 2006 01:22 PM
time/distance calculation =?Utf-8?B?S0pP?= Microsoft Excel Worksheet Functions 1 20th Apr 2005 09:13 PM
Distance calculation for lat/lon's? =?Utf-8?B?QWdlbGVzc1dvbmRlcg==?= Microsoft Access Queries 5 14th Jan 2005 04:41 PM
Calculation of distance Martin Thorson Microsoft Excel Worksheet Functions 0 25th Jul 2003 08:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:59 PM.