if (requireNamespace("sf", quietly = TRUE)) {
auckland <- sf::st_read(system.file("shapes/auckland.gpkg", package="spData")[1])
plot(sf::st_geometry(auckland))
if (requireNamespace("spdep", quietly = TRUE)) {
auckland.nb <- spdep::poly2nb(auckland)
}
}
Run the code above in your browser using DataLab