rgeoda
rgeoda copied to clipboard
Weight creation from polygons wrong
It seems that queen_weights()
is wrong (unzip attached file) in CRAN version 0.0.8.3:
chk.zip
library(sf)
chk <- st_read("chk.gpgk")
library(rgeoda)
get_neighbors(rook_weights(chk, precision_threshold=sqrt(.Machine$double.eps)), 1)
get_neighbors(queen_weights(chk, precision_threshold=sqrt(.Machine$double.eps)), 1)
library(spdep)
poly2nb(chk, queen=FALSE)[[1]]
poly2nb(chk, queen=TRUE)[[1]]
From examining the geometries, the single coordinate on the borders of 1 and 6 is ignored:
plot(st_geometry(chk))
text(st_coordinates(st_centroid(st_geometry(chk))))
Thank you, @rsbivand I can replicate it on my side. I was able to locate the issue in the libgeoda code: it is a bug that the double-precision epsilon was not handled in the weights creation code. I will commit a fix and create a new build.
Thanks, I can confirm that this works now as expected!