Neighbourhood matrix

You can use glist argument of nb2mat() to replace the 0 / 1 value from the neighbours list by preset weights.

For example, calculate inverse distance weights and feed them to nb2mat().

dists <- nbdists(nb1, centroids)
head(dists)
## [[1]]
## [1] 0.5987183 0.5796856
## 
## [[2]]
## [1] 0.5987183 0.7118774 0.3397537
## 
## [[3]]
## [1] 0.5796856 0.7118774 0.5609564 0.5233702
## 
## [[4]]
## [1] 0.3397537 0.5609564 0.6901508 0.3163691
## 
## [[5]]
## [1] 0.5233702 0.6901508 0.7533395 0.5224120 0.7162096 0.4630569 0.5558526
## [8] 0.7560518
## 
## [[6]]
## [1] 0.7533395 0.5429878