Dear All,
I am trying to choose k nearest neighbors in order to assign neighbors
based on the distance. This is just a preliminary approach to use moran
scatterplot to filter out the yield values that appear grossly discordant.

#### Choose K nearest points as neighbors
cords <- coordinates(canocrop.sp)
*spatial.knn <- knearneigh(coords, k=4)*
When I execute the last statement, the warning message is


Warning message:In library(package, lib.loc = lib.loc, character.only
= TRUE, logical.return = TRUE,  :
  there is no package called ‘RANN’

I proceed further as follows

## convert a 'knn' object returned by 'knearneigh' into a neighbor list of
class 'nb'
spatnnl<-knn2nb(spatial.knn)
## nearest distance based neighbors
spatdist<-max(unlist(nbdists(spatnnl,coords)))


summary(spatdist)
The result obtained is

 Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  117.1   117.1   117.1   117.1   117.1   117.1


My worry is how come the summary statistics are the same. I guess the
distance is wrong due to error message above. Please what do I do to my
script to prevent the above error message.

Thanks
Moshood

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to