Jan Holstein
2014-Mar-20 12:47 UTC
dnearneigh::spdep: undesired behaviour with SpatialPoints object: bug or feature? Please confirm.
I noticed that dnearneigh::spdep shows diverging behaviour with matrix and SpatialPoints objects respectively: reproducible example: library(spdep) set.seed(5) spdf<-SpatialPointsDataFrame(cbind(lon=runif(1000,2,8),lat=runif(1000,53,56)), data=data.frame(par=runif(1000,0,1)),coords.nrs numeric(0),proj4string=CRS("+init=epsg:4326")) dnearneigh(x=coordinates(spdf), d1=0, d2=20,longlat = TRUE) #Neighbour list object: #Number of regions: 1000 #Number of nonzero links: 9504 #Percentage nonzero weights: 0.9504 #Average number of links: 9.504 #2 regions with no links: #449 619 but ... dnearneigh(as(spdf,"SpatialPoints"), 0, 20,longlat = TRUE) #Neighbour list object: #Number of regions: 1000 #Number of nonzero links: 999000 #Percentage nonzero weights: 99.9 #Average number of links: 999 it seems that 'dnearneigh' ignores longlat=TRUE if class(x)==SpatialPoints, since dnearneigh(x=coordinates(spdf), d1=0, d2=20,longlat = FALSE) #Neighbour list object: #Number of regions: 1000 #Number of nonzero links: 999000 #Percentage nonzero weights: 99.9 #Average number of links: 999 gives the same 'undesired' result. - can you confirm this behavior? - is this a bug (to it feels like on) or did I overlook the greater picture and this is a feature?? R version 2.15.3 (2013-03-01) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) other attached packages: [1] spdep_0.5-56 coda_0.16-1 deldir_0.0-21 maptools_0.8-23 foreign_0.8-53 nlme_3.1-108 [7] MASS_7.3-23 Matrix_1.0-12 lattice_0.20-15 boot_1.3-7 sp_1.0-8 ----- Jan M. Holstein, Dept. Functional Ecology, Alfred Wegener Institut for Polar and Marine Research (AWI) -- View this message in context: http://r.789695.n4.nabble.com/dnearneigh-spdep-undesired-behaviour-with-SpatialPoints-object-bug-or-feature-Please-confirm-tp4687200.html Sent from the R help mailing list archive at Nabble.com.