build_adjacency_matrix: Build adjacency matrix

Description Usage Arguments Value

View source: R/spatial_data_functions.R

Description

Builds a matrix describing adjacency between polygons in the a spatial object. This function is a wrapper of two functions in the spdep package.

Usage

1
2
3
4
5
6
build_adjacency_matrix(
  poly_sp,
  style = "B",
  allow_zero_neighbors = TRUE,
  manually_add_links = list()
)

Arguments

poly_sp

A SpatialPolygonsDataFrame object

style

One of "B","W","C", or "S". For more information, see the documentation in the spdep package: https://www.rdocumentation.org/packages/spdep/versions/1.1-3/topics/nb2mat

allow_zero_neighbors

[bool, default TRUE] Allow polygons with no neighbors?

manually_add_links

[list, default NULL] A list of links to add in addition to those specified by polygon adjacency. This should be formatted as a list where each item is a numeric vector of length 2, specifying the indices of polygons that should be listed as adjacent. The numeric vectors are not sensitive to ordering (so item 'c(1, 3)' is the same as 'c(3, 1)')

Value

sparse dsCMatrix representing adjacency between polygons in the 'poly_sp' object


njhenry/covidemr documentation built on Feb. 2, 2022, 2:31 a.m.