473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

indexing lat lon

I have the following situation:

I'm developing an reverse geocoder, so input is lat/lon coordinate and
output is the nearest textual location.
I have a database of +- 2 000 000 records that contains lat/lon and full
name of the location.

These are the steps I take now:
1 'draw' a box around the lat/lon position we have as input
2 search the DB for all the points in this box
3 measure the distance to each point in the box

This works fine, but step 2 takes too lang for obvious reasons...
select * from table
where lat between box_point1_lat and box_point2_lat
and lon between box_point1_lon and box_point2_lon;

This would require a seq scan for but indexing the table doesn't help much
either (factor 2) ...

Is there a good way of indexing the lat/lon column so lookup is faster? I
have looked at PostGis but didn't think it would give a good solution in
this context (correct me if I'm wrong)

__________________________________________________ _______________
Plannen om een nieuwe computer te kopen? Kijk eens hier..
http://www.msn.be/shopping/dell_bis/
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #1
2 1826
"Jonathan Raemdonck" <jo****************@hotmail.com> writes:
These are the steps I take now:
1 'draw' a box around the lat/lon position we have as input
2 search the DB for all the points in this box
3 measure the distance to each point in the box
Right. All you need is an index amenable to step 2.
Is there a good way of indexing the lat/lon column so lookup is faster?


Yeah, you can store the lat/long as a point, build an rtree index on it,
and use box-overlap as the indexable operator. I seem to recall that
you actually have to store the lat/long as a box of zero size to get
this to work with the present set of rtree-indexable operators. If you
look in the archives you will find some previous similar cases.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #2
Jonathan,

you may try contrib/pgsphere http://www.pgastro.org/cgi-bin/wiki.pl?pgSphere
On Sun, 27 Jun 2004, Jonathan Raemdonck wrote:
I have the following situation:

I'm developing an reverse geocoder, so input is lat/lon coordinate and
output is the nearest textual location.
I have a database of +- 2 000 000 records that contains lat/lon and full
name of the location.

These are the steps I take now:
1 'draw' a box around the lat/lon position we have as input
2 search the DB for all the points in this box
3 measure the distance to each point in the box

This works fine, but step 2 takes too lang for obvious reasons...
select * from table
where lat between box_point1_lat and box_point2_lat
and lon between box_point1_lon and box_point2_lon;

This would require a seq scan for but indexing the table doesn't help much
either (factor 2) ...

Is there a good way of indexing the lat/lon column so lookup is faster? I
have looked at PostGis but didn't think it would give a good solution in
this context (correct me if I'm wrong)

__________________________________________________ _______________
Plannen om een nieuwe computer te kopen? Kijk eens hier..
http://www.msn.be/shopping/dell_bis/
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


Regards,
Oleg
__________________________________________________ ___________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: ol**@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Hilde Roth | last post by:
This may have been asked before but I can't find it. If I have a rectangular list of lists, say, l = ,,], is there a handy syntax for retrieving the ith item of every sublist? I know about for i...
15
by: Jay | last post by:
Hello all. I've recently transferred our web sites from a Windows2000 server to a Windows2003 server. The transfer went almost flawless until I noticed that our search function isn't working...
1
by: Danny | last post by:
sorry for posting a question that has probably been posted hundreds of times, but i can't seem to find the answer i need...We're using a Sql Server 7.0 database and recently started getting timeout...
108
by: Bryan Olson | last post by:
The Python slice type has one method 'indices', and reportedly: This method takes a single integer argument /length/ and computes information about the extended slice that the slice object would...
10
by: Lyle Fairfield | last post by:
By default mdb etc files are not searched by Indexing Service. The default can be changed in Windows XP Pro using Group Policy. I can find no suggested way to make the change in the Windows XO...
7
by: Ryan | last post by:
I have a bit of a problem with regards an indexing strategy. Well, basically there is no indexing strategy on a set of data I have at work. Now, I didn't create the design as I would have allowed...
3
by: Chung Leong | last post by:
Here's the rest of the tutorial I started earlier: Aside from text within a document, Indexing Service let you search on meta information stored in the files. For example, MusicArtist and...
4
by: Emin | last post by:
Dear Experts, How much slower is dict indexing vs. list indexing (or indexing into a numpy array)? I realize that looking up a value in a dict should be constant time, but does anyone have a...
4
by: pratimapaudel | last post by:
I have tables in my database, it's sql server 2005. I heard some of them have indexing and some of them doesnot have indexing. If i want to check whether it has indexing or not how do i do? ...
2
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a server 2008 IIS 7.0 with indexing service installed. I have created the catalog and have a test page using these posts:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.