14.8 Graph-Based Neighbors

The simplest form is by using triangulation, here using the deldir package

# get centroids and save their coordinates
pol_pres15 |> 
    st_geometry() |> 
    st_centroid(of_largest_polygon = TRUE) -> coords 

# triangulation
(coords |> tri2nb() -> nb_tri)
## Neighbour list object:
## Number of regions: 2495 
## Number of nonzero links: 14930 
## Percentage nonzero weights: 0.2398384 
## Average number of links: 5.983968

14.8.1 How Far Away are the Neighbors?

# results in meters
nb_tri |> 
    nbdists(coords) |> 
    unlist() |> 
    summary()
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##    246.6   9847.2  12151.2  13485.2  14993.5 296973.7

14.8.2 Sphere of Influence

The Sphere of Influence soi.graph function takes triangulated neighbours and prunes off neighbour relationships represented by edges that are unusually long for each point.

(nb_tri |> 
        soi.graph(coords) |> 
        graph2nb() -> nb_soi)
## Neighbour list object:
## Number of regions: 2495 
## Number of nonzero links: 12792 
## Percentage nonzero weights: 0.2054932 
## Average number of links: 5.127054 
## 16 disjoint connected subgraphs
# Poland
pol_pres15 |> 
    st_geometry() |> 
    plot(border = "grey", lwd = 0.5)

# triangulation
plot(nb_tri, 
     coords = coords, points = FALSE, lwd = 0.5)

# sphere of influence
plot(nb_soi, 
     coords = coords, points = FALSE, lwd = 0.5)