s-news
[Top] [All Lists]

Euclidean distance in find.neighbor

To: <s-news@wubios.wustl.edu>
Subject: Euclidean distance in find.neighbor
From: "Volker Bahn" <lochapoka@web.de>
Date: Wed, 24 Nov 2004 17:11:09 -0500
Dear list members,

I am trying to implement a toroidal correction in a 10x10 matrix (meaning 
that for example cells on the left edge are direct neighbors to cells on the 
right edge). I wanted to achieve this by recalculating the distances in a 
neighborhood matrix created with find.neighbor() from module(spatial). I 
first recalculated the distances as they should be in the neighborhood 
matrix and found a surprising deviation. For example the cell pair with 
coordinates (1,1) and (10,10) should have a Euclidean distance of
> sqrt(2*9^2)
[1] 12.72792
However, in the matrix created by find.neighbor() the corresponding distance 
is:
> x12.nhbr[1,3]
[1] 12.75879

Can anyone enlighten me why the numbers differ? The find.neighbor function 
calls on a C routine for finding the distances, so I cannot look at the code 
directly.

I'm using Splus 6.1 for Windows on a Windows XP pro computer.

Thanks

Volker

_______________________________

Volker Bahn

Dept. of Wildlife Ecology - Rm. 210
University of Maine
5755 Nutting Hall
Orono, Maine
04469-5755, USA
Tel. (207) 581 2799
Fax: (207) 581 2858
volker.bahn@umit.maine.edu
http://www.wle.umaine.edu/used_text%20files/Volker%20Bahn/home.htm 


<Prev in Thread] Current Thread [Next in Thread>
  • Euclidean distance in find.neighbor, Volker Bahn <=