What would be the best technique to use to get all the addresses in my
DB that are , say, within 10 miles of a given postcode?
Each of my addresses has a postcode.
Does anyone have any experience of doing this? any input would be
greatly appreciated.
Thanks
Chris
Hi Chris,
You need the expensive Postcode Address File:
http://www.royalmail.com/portal/rm/jump2?mediaId=400085&catId=400084
There is a campaign to make this information freely available (as it
is for ZIP codes in the USA):
http://www.freethepostcode.org/
Cheers, Olly.
–
www.lylo.co.uk
On Aug 7, 5:33 pm, Chris R. [email protected]
Hi Chris,
You need the expensive Postzon Data:
http://www.royalmail.com/portal/rm/content3?mediaId=55900704&catId=400088
There is a campaign to make this information freely available (as it
is for ZIP codes in the USA):
http://www.freethepostcode.org/
Cheers, Olly.
–
www.lylo.co.uk
On Aug 7, 5:33 pm, Chris R. [email protected]
Isn’t it possible to geocode a postcode into latitude/longitue using a
webservice, and then calculate the distances from that?
Chris -
On 7-Aug-07, at 5:09 PM, Chris R. wrote:
Isn’t it possible to geocode a postcode into latitude/longitue using a
webservice, and then calculate the distances from that?
I’ve just started using this one:
http://geokit.rubyforge.org/
check out Ben’s plugin directory for others:
http://agilewebdevelopment.com/plugins
cheers,
Jodi
Chris -
On 8-Aug-07, at 11:59 AM, Chris R. wrote:
Is there a way to calculate the distance between two lat/longs without
connecting to an external location?
Im guessing there is a fairly simple way to do it?
Thanks
Chris
Generally you should geocode all your current addresses - store the
long and lat for each. Then geocode each address as it’s added.
Then you can use geokit to calculate distances, etc.
make sense?
Jodi
I’ve just started using this one:
http://geokit.rubyforge.org/
check out Ben’s plugin directory for others:
http://agilewebdevelopment.com/plugins
cheers,
Jodi
Thanks, i think ill use that for my geocoding.
Is there a way to calculate the distance between two lat/longs without
connecting to an external location?
Im guessing there is a fairly simple way to do it?
Thanks
Chris
If you are going to do stuff like select all database rows in a
certain range of a point (within 10 miles of a point) and need any
kind of performance at all, I would HIGHLY suggest that you use a
database that has geometric types built in. As long as you can build
an index on a geometric type and do searches using that index, then go
for it.
I glanced over geokit really quick and it uses the geometric formulas
straight in the sql query, which means that the database is going to
have to do a sequential scan performing the “expensive” mathmatical
operations for every row in your table each time you do a query.
Anyway, my point is, pick the right tool for the job.
On 8/8/07, Jodi S. [email protected] wrote:
cheers,
Chris
–
EPA Rating: 3000 Lines of Code / Gallon (of coffee)
Jodi S. wrote:
Chris -
On 8-Aug-07, at 11:59 AM, Chris R. wrote:
Is there a way to calculate the distance between two lat/longs without
connecting to an external location?
Im guessing there is a fairly simple way to do it?
Thanks
Chris
Generally you should geocode all your current addresses - store the
long and lat for each. Then geocode each address as it’s added.
Then you can use geokit to calculate distances, etc.
make sense?
Jodi
thanks Jodi,
but thats what I said
“I glanced over geokit really quick and it uses the geometric formulas
straight in the sql query,” is what i really wanted to know
A database with geometric types built in would be the best option, but
assuming you don’t have that…
(And I’m only brainstorming here, I haven’t tried any technique or
looked at Geokit.)
It might be less “expensive” to pull records from the database where
the latitude or longitude was plus or minus 10 miles from a point and
then calculate the geometry on those records to determine which are
actually 10 miles from the point and sort them. Basically, retrieve a
rough square and then narrow it down to a precise circle. It would
save you from performing the geometry on every address in the
database, including addresses on the other side of the planet.
Kevin S.
Postgresql (http://www.postgresql.org/) has geometric types and
functions.
This tends to be my preference.
Carl L. wrote:
If you are going to do stuff like select all database rows in a
certain range of a point (within 10 miles of a point) and need any
kind of performance at all, I would HIGHLY suggest that you use a
database that has geometric types built in. As long as you can build
an index on a geometric type and do searches using that index, then go
for it.
Do you have any suggestions on dbs with built-in geometrics?
On 8/8/07, Carl L. [email protected] wrote:
This tends to be my preference.
On 8/8/07, s.ross [email protected] wrote:
Postgresql (http://www.postgresql.org/) has geometric types and
functions.
Be prepared for a bit of work. For example with postgis you can do a
proximity search but the sql can get rather complex, and you have to
translate points into meters, miles, or whatever unit of measure you
are after. A search of the postgis archives should turn up pretty
much everything you need.
What we did was use the perl code from geocoder.us to put the whole US
TIGER dataset into a dbm file, and used that to get the lat/long for
an address. It’s not complete so we would fall back to the google api
if it wasn’t found. The google geocoding api and all other free api’s
have a limit on how many queries you can do per second, so if you are
geocoding a large number of addresses you are better off having a
local database to geocode against.
Chris