[R-sig-Geo] dnearneigh() from spdep: Points with the exact same location are not considered neighbours.

Maël Le Noc mael.lenoc at laposte.net
Wed Apr 12 03:14:03 CEST 2017


Dear List

As I was working on a project, I realized that when I use dnearneigh
from spdep, two (or more) points that have the exact same coordinates
are not considered neighbours and thus are not linked (even when the
lower bound is put to 0 or even to -1). See below for an example.
(However this does not happen if the parameter longlat is set to false)

 Does the function behave the same way for you? Am I missing something?
Is this an expected behavior? And if so, if there a way to change that ?

In the example below, points 1 and 2 are not connected to each other/are
not neighbours (as you can see since the both have only one link, to 3),
even though they have the exact same coordinates (and are thus less than
25km apart), while point 3 is connected to both point 1 and 2.
If I want to assess autocorrelation using, for instance joincount.test,
this is then an issue...

>/library(data.table) />/library(spdep) />/pointstable <- data.table(XCoord=c(13.667029,13.667029,13.667028), /YCoord=c(42.772396,42.772396,42.772396))
>/print(pointstable) /     XCoord  YCoord
1: 13.667029 42.772396
2: 13.667029 42.772396
3: 13.667028 42.772396
>/coords <-cbind(pointstable$XCoord, pointstable$YCoord) />/nbLocal<- dnearneigh(coords, d1=0, d2=25, longlat = TRUE) />/nbLocal<- dnearneigh(coords, d1=-1, d2=25, longlat = TRUE) #both lines /produce the same output
>/summary(nbLocal) /Neighbour list object:
Number of regions: 3
Number of nonzero links: 4
Percentage nonzero weights: 44.44444
Average number of links: 1.333333
Link number distribution:

1 2
2 1
2 least connected regions:
1 2 with 1 link
1 most connected region:
3 with 2 links
>//
Thanks
Maël


	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list