Create a Queen contiguity weights with options of "order", "include lower order" and "precision threshold"
queen_weights(
sf_obj,
order = 1,
include_lower_order = FALSE,
precision_threshold = 0
)
An sf (simple feature) object
(Optional) Order of contiguity
(Optional) Whether or not the lower order neighbors should be included in the weights structure
(Optional) The precision of the underlying shape file is insufficient to allow for an exact match of coordinates to determine which polygons are neighbors
An instance of Weight-class
library(sf)
guerry_path <- system.file("extdata", "Guerry.shp", package = "rgeoda")
guerry <- st_read(guerry_path)
#> Reading layer `Guerry' from data source
#> `/Users/runner/work/_temp/Library/rgeoda/extdata/Guerry.shp'
#> using driver `ESRI Shapefile'
#> Simple feature collection with 85 features and 29 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: 47680 ymin: 1703258 xmax: 1031401 ymax: 2677441
#> Projected CRS: NTF (Paris) / Lambert zone II
queen_w <- queen_weights(guerry)
summary(queen_w)
#> name value
#> 1 number of observations: 85
#> 2 is symmetric: TRUE
#> 3 sparsity: 0.0581314878892734
#> 4 # min neighbors: 2
#> 5 # max neighbors: 8
#> 6 # mean neighbors: 4.94117647058824
#> 7 # median neighbors: 5
#> 8 has isolates: FALSE