Unambiguous Neighborhoods with spdep
Extra Writeups
(0) Initialization Code
(This code cell is set to auto-run upon page load!)
(1) Finding Neighbors in Asia
(1.1) Download Countries as POLYGONs from rnaturalearth
Here we use rnaturalearth::ne_countres(), with the continent option. We specify scale=50 since otherwise smaller countries like Bahrain get excluded!
(1.2) Detecting Neighbors with spdep::poly2nb()
Given an sf object, spdep::poly2nb() identifies all pairs of touching POLYGONs.