Dietrich Kastens wrote:
> Does anyone know of any code out there that would allow me to find a
> neareast nieghbor point to another point.  In Mapbasic, the geographic

Here's the algorithm:

Extract X and Y coordinates of your point
Select all OTHER points
Extract X and Y coordinates and RowId of first other point
Set NearestDistance = Distance between the two points 
 (Use MapInfo's Distance() function for this)
Set NearestId = RowId
For each other point
  Extract X and Y coordinates and RowId
  Calculate Distance between the two points
  If Distance < NearestDistance
     Set NearestId = RowId
     Set NearestDistance = Distance
   

After this loop finishes, the Row Id of the nearest point is NearestId,
and you can use Fetch on the selection of other points to retrieve it.

- Bill Thoen
------------------------------------------------------------
GISnet, 1401 Walnut St., Suite C, Boulder, CO  80302
tel: 303-786-9961, fax: 303-443-4856
mailto:[EMAIL PROTECTED], http://www.ctmap.com/gisnet
------------------------------------------------------------


_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.

Reply via email to