Create a Rook contiguity weights with options of "order", "include lower order" and "precision threshold"

rook_weights(
  sf_obj,
  order = 1,
  include_lower_order = FALSE,
  precision_threshold = 0
)

Arguments

sf_obj

An sf (simple feature) object

order

(Optional) Order of contiguity

include_lower_order

(Optional) Whether or not the lower order neighbors should be included in the weights structure

precision_threshold

(Optional) The precision of the underlying shape file is insufficient to allow for an exact match of coordinates to determine which polygons are neighbors

Value

An instance of Weight-class

Examples

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
rook_w <- rook_weights(guerry)
summary(rook_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