ArcMap allows for a spatial join with the parameter CLOSEST.
Would it be possible to implement this as a feature via something like st_closest(x, y, ...)?
There is, afaics, not a function in GEOS that we can use for this, so the implementation would have to use st_distance, and then select the closest. So possible yes, but it wouldn't scale nicely, nor be efficient.
I believe an equivalent to postgis st_dwithin could be useful for a spatial join based on proximity, but it doesn't solve your immediate problem. I'd be interested to know how k-NN packages scale that problem?
If two sets of points are represented as matrices I guess that would work. There are loads of options including knn() in base R and this one: https://github.com/davpinto/fastknn
Appreciate this is closed and not asking as a feature request but just out of curiosity would that be possible?
Update: I've been using the nabor package and it works great on 2 sets of matrices: https://cran.r-project.org/package=nabor
That would be my default strategy and, having used it in stplanr I guess it would be fast and scalable, and really useful, either as st_nearest(x, y) which could go straight into st_join() or as a closest parameter as the original post suggested.
I think this would be a great feature (see, this question and this question)
See here: https://github.com/r-spatial/sf/issues/990#issuecomment-468575158
Most helpful comment
Update: I've been using the nabor package and it works great on 2 sets of matrices: https://cran.r-project.org/package=nabor
That would be my default strategy and, having used it in stplanr I guess it would be fast and scalable, and really useful, either as
st_nearest(x, y)which could go straight intost_join()or as a closest parameter as the original post suggested.