Hi Lee,

You are correct, that 2 copies are needed. But before making the copy
add an integer field ("dummyfield") with all 0's to the original table.
Then run this query:

select table1.id,table2.id
where table1.dummyfield=table2.dummyfield and table1.id<table2.id and
distance(centroidX(table1.obj),centroidY(table1.obj),centroidX(table2.ob
j),centroidY(table2.obj),"mi")<20

You may also like to include the distance in the output.

This is slow: With just 1900 points it took 9 minutes, when 4892 records
where returned on some random data.

With mapbasic, it may be faster to run 1900 "select within radius"
queries, but I haven' tried that.

And now a commercial:
In my ToolBox I have just added a function for doing this sort of
selection "slightly" faster. It can select the n nearest points in one
table for all points in another table, eventually combined with a
distance-restriction as you have. On the same data as above, that took 5
seconds, or 60 times faster.

This function is still not available at the website (see signature), but
I can send you a demo if needed - it will be restricted to 100 points in
your dataset.

Kind regards

Uffe Kousgaard
www.routeware.dk


----- Original Message ----- 
From: "Lee Wold" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, July 05, 2003 11:27 AM
Subject: MI-L Calculate distance from Table of postcode points


I have a table with four columns as follows :
Code    Name    Type    Postcode

It has approx 1900 points.

I want to write an SQL query that takes each point in the table and
compares it with every other point in the table and creates a new table
where the distance between any two points is less than 20 miles.

I am sure this is possible (and I think I will need two copies of the
table to perform this query) but I am very new to Mapinfo and still
learning!

Any help would be greatly appreciated.


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 7506

Reply via email to