an><span class="fu">spdep</span><span class="fu">::</span><span class="fu"><a href="https://r-spatial.github.io/spdep/reference/knearneigh.html" class="external-link">knearneigh</a></span><span class="op">(</span><span class="va">coords1</span>, k <span class="op">=</span> <span class="fl">4</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="va">coords2</span> <span class="op">&lt;-</span> <span class="fu">sf</span><span class="fu">::</span><span class="fu"><a h