Postcode Distance Calculator UK

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Postcode Distance Calculator UK

Stephen Thirlwell
Hi

Does anyone have a distance calculator working for UK postcodes?
 
Listsearch is down at the moment so apologies if the answers to this is in
the archive ;)

Regards

Stephen



------------------------------
LASSO MASTER CLASS - Orlando, FL
Following the FileMaker Developer Conference
2 Day intensive seminar: Learn the best way to get your FileMaker data on the web.
http://www.briandunning.com/lasso-training/


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Postcode Distance Calculator UK

Bil Corry
All you need is a database of lat/lon coordinates for each postal code and this ctag to do the distance calculation:

   <http://tagswap.net/lp_math_GPSdistance>


- Bil


Stephen Thirlwell wrote:

> Hi
>
> Does anyone have a distance calculator working for UK postcodes?
>  
> Listsearch is down at the moment so apologies if the answers to this is in
> the archive ;)
>
> Regards
>
> Stephen


------------------------------
LASSO MASTER CLASS - Orlando, FL
Following the FileMaker Developer Conference
2 Day intensive seminar: Learn the best way to get your FileMaker data on the web.
http://www.briandunning.com/lasso-training/


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Postcode Distance Calculator UK

John Williscroft
In reply to this post by Stephen Thirlwell
Hi Stephen
You have to look up the position of the post-codes in a database  
first - there are various versions of the latter depending on how  
accurate you want to be (and how much you want to pay / how big a  
postcode database you want). There are also on-line look-ups  
available. <http://nearby.org.uk/> and <www.graticule.com/data/
postcode/index.html> are a good place to start.

I've used the (free) rough data to work out 'nearest shop' for a  
couple of Lasso sites if that's helpful - contact me off-list.

best rgds
john

On 26 Jul 2006, at 11:18, Stephen Thirlwell wrote:

> Hi
>
> Does anyone have a distance calculator working for UK postcodes?
>
> Listsearch is down at the moment so apologies if the answers to  
> this is in
> the archive ;)
>
> Regards
>
> Stephen


John Williscroft,  iCatching Design Ltd
www.icatching.eu   t:0845 644 2884   f:0871 733 5358    
[hidden email]
graphic design | web-design | ecommerce | print design




------------------------------
LASSO MASTER CLASS - Orlando, FL
Following the FileMaker Developer Conference
2 Day intensive seminar: Learn the best way to get your FileMaker data on the web.
http://www.briandunning.com/lasso-training/


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Postcode Distance Calculator UK

stevepiercy
In reply to this post by Stephen Thirlwell
I have a US ZIP code distance calculator.  You can use the same Lasso code, but you will need to add your own data for the UK.  The database table consists of 4 columns: ZIP Code, State, Latitude, Longitude.
<http://www.StevePiercy.com/lasso_stuff/zipdist/distance.lasso>

--steve


On Wednesday, July 26, 2006, [hidden email] (Stephen Thirlwell) pronounced:

>Hi
>
>Does anyone have a distance calculator working for UK postcodes?
>
>Listsearch is down at the moment so apologies if the answers to this is in
>the archive ;)
>
>Regards
>
>Stephen
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy               Web Site Builder               Soquel, CA
<[hidden email]>                   <http://www.StevePiercy.com>

------------------------------
LASSO MASTER CLASS - Orlando, FL
Following the FileMaker Developer Conference
2 Day intensive seminar: Learn the best way to get your FileMaker data on the web.
http://www.briandunning.com/lasso-training/


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Postcode Distance Calculator UK

Greg Hemphill
I'm wondering if anyone has created something that will let you enter  
a zip code and the a mile range, and it will spit out a list of zip  
codes that fall within that milage radius.  Seems like it could be  
really useful for any site with a store locator.

BTW.  That a pretty cool app Steve!

Greg


On Jul 26, 2006, at 2:42 PM, Steve Piercy - Web Site Builder wrote:

> I have a US ZIP code distance calculator.  You can use the same  
> Lasso code, but you will need to add your own data for the UK.  The  
> database table consists of 4 columns: ZIP Code, State, Latitude,  
> Longitude.
> <http://www.StevePiercy.com/lasso_stuff/zipdist/distance.lasso>
>
> --steve
>
>
> On Wednesday, July 26, 2006, [hidden email] (Stephen  
> Thirlwell) pronounced:
>
>> Hi
>>
>> Does anyone have a distance calculator working for UK postcodes?
>>
>> Listsearch is down at the moment so apologies if the answers to  
>> this is in
>> the archive ;)
>>
>> Regards
>>
>> Stephen
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy               Web Site Builder               Soquel, CA
> <[hidden email]>                   <http://www.StevePiercy.com>
>
> ------------------------------
> LASSO MASTER CLASS - Orlando, FL
> Following the FileMaker Developer Conference
> 2 Day intensive seminar: Learn the best way to get your FileMaker  
> data on the web.
> http://www.briandunning.com/lasso-training/
>
>
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription:
> http://www.listsearch.com/lassotalk.lasso?manage


------------------------------
LASSO MASTER CLASS - Orlando, FL
Following the FileMaker Developer Conference
2 Day intensive seminar: Learn the best way to get your FileMaker data on the web.
http://www.briandunning.com/lasso-training/


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Postcode Distance Calculator UK

stevepiercy
There are two ways to do this.

One is the brute force calculation method, whereby a person selects one ZIP code and a distance radius.  The app calculates the distance from ZIP A to all ZIP codes in the table, and displays only those that are within range.  The disadvantage to this method is that it means potentially a LOT of calculations for every search.

The second is to do the calculations up front, and store the ZIP codes in an array, like so:

ZIP A   5-mile range ZIPs   10-mile range ZIPs  
12345   12346,12347,12348   12346,12347,12348,12349
12346   12345,12347,12348   12345,12347,12348,12349

The latter would save time in performing calculations during the search, but it means that every time your ZIP codes split/change, you have to recalculate the entire table.  From a user perspective the latter method would be better (faster) provided that the data are accurate.

One thing to note is that the ZIP code database is very, very approximate.  A US ZIP code can cover a large area, like 5 miles x 5 miles, especially in suburban and rural areas.  If you need greater accuracy, you will need a more accurage data source that has latitude and longitude mapped to street addresses.

--steve


On Thursday, July 27, 2006, [hidden email] (Greg Hemphill) pronounced:

>I'm wondering if anyone has created something that will let you enter  
>a zip code and the a mile range, and it will spit out a list of zip  
>codes that fall within that milage radius.  Seems like it could be  
>really useful for any site with a store locator.
>
>BTW.  That a pretty cool app Steve!
>
>Greg
>
>
>On Jul 26, 2006, at 2:42 PM, Steve Piercy - Web Site Builder wrote:
>
>> I have a US ZIP code distance calculator.  You can use the same  
>> Lasso code, but you will need to add your own data for the UK.  The  
>> database table consists of 4 columns: ZIP Code, State, Latitude,  
>> Longitude.
>> <http://www.StevePiercy.com/lasso_stuff/zipdist/distance.lasso>
>>
>> --steve
>>
>>
>> On Wednesday, July 26, 2006, [hidden email] (Stephen  
>> Thirlwell) pronounced:
>>
>>> Hi
>>>
>>> Does anyone have a distance calculator working for UK postcodes?
>>>
>>> Listsearch is down at the moment so apologies if the answers to  
>>> this is in
>>> the archive ;)
>>>
>>> Regards
>>>
>>> Stephen
>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>> Steve Piercy               Web Site Builder               Soquel, CA
>> <[hidden email]>                   <http://www.StevePiercy.com>
>>
>> ------------------------------
>> LASSO MASTER CLASS - Orlando, FL
>> Following the FileMaker Developer Conference
>> 2 Day intensive seminar: Learn the best way to get your FileMaker  
>> data on the web.
>> http://www.briandunning.com/lasso-training/
>>
>>
>> ------------------------------
>> Lasso Support: http://support.omnipilot.com/
>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>> Manage your list subscription:
>> http://www.listsearch.com/lassotalk.lasso?manage
>
>
>------------------------------
>LASSO MASTER CLASS - Orlando, FL
>Following the FileMaker Developer Conference
>2 Day intensive seminar: Learn the best way to get your FileMaker data on the web.
>http://www.briandunning.com/lasso-training/
>
>
>------------------------------
>Lasso Support: http://support.omnipilot.com/
>Search the list archives: http://www.listsearch.com/lassotalk.lasso
>Manage your list subscription:  
>http://www.listsearch.com/lassotalk.lasso?manage
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy               Web Site Builder               Soquel, CA
<[hidden email]>                   <http://www.StevePiercy.com>

------------------------------
LASSO MASTER CLASS - Orlando, FL
Following the FileMaker Developer Conference
2 Day intensive seminar: Learn the best way to get your FileMaker data on the web.
http://www.briandunning.com/lasso-training/


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Postcode Distance Calculator UK

Bil Corry
There's a third way, you can use this ctag:

  <http://tagswap.net/lp_math_GPSradius>

Basically, take your zip code, lookup the lat/lon for it, plug it into [lp_math_GPSradius] along with the desired radius (it has five different units of measure), it will then return a lower lat/lon and an upper lat/lon - take those and search for any zips that fall between them (assuming you have a database of zips with lon/lat).  Because the search is actually a square instead of a circle (aka radius), there is the chance that some are actually a smidge farther than you wanted.  You can either leave it at that, or individually check the distance of each found row by using:

  <http://tagswap.net/lp_math_GPSdistance>

The WHERE part of your SQL query should look something like this:

        m.lat >= "+($radius->lat_low)+"  and
        m.lat <= "+($radius->lat_high)+" and
        m.lon >= "+($radius->lon_low)+" and
        m.lon <= "+($radius->lon_high)+"

One of these days I'll write up an article with more detail for ldml.org, until then, HTH...


- Bil


Steve Piercy - Web Site Builder wrote:

> There are two ways to do this.
>
> One is the brute force calculation method, whereby a person selects one ZIP code and a distance radius.  The app calculates the distance from ZIP A to all ZIP codes in the table, and displays only those that are within range.  The disadvantage to this method is that it means potentially a LOT of calculations for every search.
>
> The second is to do the calculations up front, and store the ZIP codes in an array, like so:
>
> ZIP A   5-mile range ZIPs   10-mile range ZIPs  
> 12345   12346,12347,12348   12346,12347,12348,12349
> 12346   12345,12347,12348   12345,12347,12348,12349
>
> The latter would save time in performing calculations during the search, but it means that every time your ZIP codes split/change, you have to recalculate the entire table.  From a user perspective the latter method would be better (faster) provided that the data are accurate.
>
> One thing to note is that the ZIP code database is very, very approximate.  A US ZIP code can cover a large area, like 5 miles x 5 miles, especially in suburban and rural areas.  If you need greater accuracy, you will need a more accurage data source that has latitude and longitude mapped to street addresses.
>
> --steve
>
>
> On Thursday, July 27, 2006, [hidden email] (Greg Hemphill) pronounced:
>
>> I'm wondering if anyone has created something that will let you enter  
>> a zip code and the a mile range, and it will spit out a list of zip  
>> codes that fall within that milage radius.  Seems like it could be  
>> really useful for any site with a store locator.
>>
>> BTW.  That a pretty cool app Steve!
>>
>> Greg


------------------------------
LASSO MASTER CLASS - Orlando, FL
Following the FileMaker Developer Conference
2 Day intensive seminar: Learn the best way to get your FileMaker data on the web.
http://www.briandunning.com/lasso-training/


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Postcode Distance Calculator UK

Fletcher Sandbeck
In reply to this post by stevepiercy
On 2006-07-27 at 12:13 by [hidden email] (Steve Piercy - Web Site Builder):

>There are two ways to do this.
>
>One is the brute force calculation method, whereby a person selects
>one ZIP code and a distance radius.  The app calculates the distance
>from ZIP A to all ZIP codes in the table, and displays only those that
>are within range.  The disadvantage to this method is that it means
>potentially a LOT of calculations for every search.
>
>The second is to do the calculations up front, and store the ZIP codes in an array, like so:
>
>ZIP A   5-mile range ZIPs   10-mile range ZIPs  
>12345   12346,12347,12348   12346,12347,12348,12349
>12346   12345,12347,12348   12345,12347,12348,12349
>
>The latter would save time in performing calculations during the
>search, but it means that every time your ZIP codes split/change, you
>have to recalculate the entire table.  From a user perspective the
>latter method would be better (faster) provided that the data are
>accurate.

This is what I've done.  I create a zipdist database which has two zip codes and the distance between them.  Then I can find any zipcodes with x miles of any zip code by searching this database.  I fill this database based on the actual zip codes which I have in my data (otherwise it can grow to up to 100 million records) and I cap the distance at my max search radius (50 or 100 miles).  Even so, this database can become quite large.

>One thing to note is that the ZIP code database is very, very
>approximate.  A US ZIP code can cover a large area, like 5 miles x 5
>miles, especially in suburban and rural areas.  If you need greater
>accuracy, you will need a more accurage data source that has latitude
>and longitude mapped to street addresses.

Yes, you can get some very weird results.  All businesses within a zip code appear to be at the same location.  You might have two business which are across the street from each other, but are in different zip codes so the database reports they are 10 miles apart.  I've usually rounded the distances to say "Less than 10 miles", "10-20 miles", etc. to try to smooth out some of these problems.

[fletcher]

--
Fletcher Sandbeck                         [hidden email]
Director of Product Development       http://www.lassostudio.com
OmniPilot Software, Inc.                http://www.omnipilot.com

------------------------------
LASSO MASTER CLASS - Orlando, FL
Following the FileMaker Developer Conference
2 Day intensive seminar: Learn the best way to get your FileMaker data on the web.
http://www.briandunning.com/lasso-training/


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Postcode Distance Calculator UK

N Lamb
In reply to this post by stevepiercy
There is a third way to do this as well...  (probably more ways too...)
  but it is using Brian Dunning's method...  which you have 3
databases...  an entry database, a "master" zip code database, and your
database with your records to search...  (all of these are "linked"
together with relationships (in FMP obviously))

What happens is you key in a zip code which is entered into the entry
database, and your database performs a lookup with the master zip code
database and returns the lat and lon of that zip in the the entry zip
database which then updates a distance field in your records database.
(get all that??)  You then perform a search of your records database
immediately using whatever distance you want searching on this distance
field...  I have a test page setup which does this and it works well...
(it is a little slow (~10 seconds per search) but it is on an older x
serve...)  I have never deployed it live as my concern is a bunch of
people "hitting" this at the same time and what would happen in said
situation...

If anyone want to see this at work email me off list and I will send
you a link...

HTH,

Nathan Lamb



On Jul 27, 2006, at 3:13 PM, Steve Piercy - Web Site Builder wrote:

> There are two ways to do this.
>
> One is the brute force calculation method, whereby a person selects
> one ZIP code and a distance radius.  The app calculates the distance
> from ZIP A to all ZIP codes in the table, and displays only those that
> are within range.  The disadvantage to this method is that it means
> potentially a LOT of calculations for every search.
>
> The second is to do the calculations up front, and store the ZIP codes
> in an array, like so:
>
> ZIP A   5-mile range ZIPs   10-mile range ZIPs
> 12345   12346,12347,12348   12346,12347,12348,12349
> 12346   12345,12347,12348   12345,12347,12348,12349
>
> The latter would save time in performing calculations during the
> search, but it means that every time your ZIP codes split/change, you
> have to recalculate the entire table.  From a user perspective the
> latter method would be better (faster) provided that the data are
> accurate.
>
> One thing to note is that the ZIP code database is very, very
> approximate.  A US ZIP code can cover a large area, like 5 miles x 5
> miles, especially in suburban and rural areas.  If you need greater
> accuracy, you will need a more accurage data source that has latitude
> and longitude mapped to street addresses.
>
> --steve
>
>
> On Thursday, July 27, 2006, [hidden email] (Greg Hemphill)
> pronounced:
>
>> I'm wondering if anyone has created something that will let you enter
>> a zip code and the a mile range, and it will spit out a list of zip
>> codes that fall within that milage radius.  Seems like it could be
>> really useful for any site with a store locator.
>>
>> BTW.  That a pretty cool app Steve!
>>
>> Greg
>>
>>
>> On Jul 26, 2006, at 2:42 PM, Steve Piercy - Web Site Builder wrote:
>>
>>> I have a US ZIP code distance calculator.  You can use the same
>>> Lasso code, but you will need to add your own data for the UK.  The
>>> database table consists of 4 columns: ZIP Code, State, Latitude,
>>> Longitude.
>>> <http://www.StevePiercy.com/lasso_stuff/zipdist/distance.lasso>
>>>
>>> --steve
>>>
>>>
>>> On Wednesday, July 26, 2006, [hidden email] (Stephen
>>> Thirlwell) pronounced:
>>>
>>>> Hi
>>>>
>>>> Does anyone have a distance calculator working for UK postcodes?
>>>>
>>>> Listsearch is down at the moment so apologies if the answers to
>>>> this is in
>>>> the archive ;)
>>>>
>>>> Regards
>>>>
>>>> Stephen
>>> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>>> Steve Piercy               Web Site Builder               Soquel, CA
>>> <[hidden email]>                   <http://www.StevePiercy.com>
>>>
>>> ------------------------------
>>> LASSO MASTER CLASS - Orlando, FL
>>> Following the FileMaker Developer Conference
>>> 2 Day intensive seminar: Learn the best way to get your FileMaker
>>> data on the web.
>>> http://www.briandunning.com/lasso-training/
>>>
>>>
>>> ------------------------------
>>> Lasso Support: http://support.omnipilot.com/
>>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>>> Manage your list subscription:
>>> http://www.listsearch.com/lassotalk.lasso?manage
>>
>>
>> ------------------------------
>> LASSO MASTER CLASS - Orlando, FL
>> Following the FileMaker Developer Conference
>> 2 Day intensive seminar: Learn the best way to get your FileMaker
>> data on the web.
>> http://www.briandunning.com/lasso-training/
>>
>>
>> ------------------------------
>> Lasso Support: http://support.omnipilot.com/
>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>> Manage your list subscription:
>> http://www.listsearch.com/lassotalk.lasso?manage
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy               Web Site Builder               Soquel, CA
> <[hidden email]>                   <http://www.StevePiercy.com>
>
> ------------------------------
> LASSO MASTER CLASS - Orlando, FL
> Following the FileMaker Developer Conference
> 2 Day intensive seminar: Learn the best way to get your FileMaker data
> on the web.
> http://www.briandunning.com/lasso-training/
>
>
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription:
> http://www.listsearch.com/lassotalk.lasso?manage
>


------------------------------
LASSO MASTER CLASS - Orlando, FL
Following the FileMaker Developer Conference
2 Day intensive seminar: Learn the best way to get your FileMaker data on the web.
http://www.briandunning.com/lasso-training/


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage