Description
I've started looking at supplementing code for finding point neighbours within distance thresholds on the sphere in spdep through sf::st_is_within_distance()
, which is OK. However, to return distances for the chosen neighbours on the sphere, in line 64 in https://github.com/r-spatial/spdep/blob/master/R/nbdists.R I iterate over subsets of points through lapply()
- see also the examples at the foot of https://r-spatial.github.io/spdep/reference/dnearneigh.html - it would be better to iterate in compiled code rather than use lapply()
. Is LinkingTo
feasible?
Finding k-nearest neighbours on the sphere looks even more complex for k > 1. Is there any such query in the s2 code itself? I looked at the documentation but couldn't see obvious opportunities, though I think they may be there somewhere, given that indexing is being used.
Current implementations use legacy C code for spdep::dnearneigh()
, spdep::nbdists()
and spdep::knearneigh()
with Great Circle WGS84 ellipsoid distances and no indexing.
Any suggestions would be very welcome!