This function is a clone of spdep::aggregate.nb with one minor modification - it does not remove areas without neighbors, because in GAT, not having neighbors matters.

aggregateGATnb(nb, ids, remove.self = TRUE)

Arguments

nb

Neighbors object.

ids

Vector of IDs corresponding to the neighbor object's "region.id" attribute.

remove.self

Boolean denoting whether to remove original areas.

Examples

nb <- spdep::poly2nb(hftown, queen = FALSE,
                     row.names = rownames(hftown))
# neighbors of areas being aggregated
nb[[12]]; nb[[13]]; nb[[20]]
#> [1]  3  4 10 13 20
#> [1]  3 12 14 16 17 18 19 20 21
#> [1] 12 13 17
ids <- c(1:12, 12, 14:19, 12, 21)
# neighbors of resulting area
aggregateGATnb(nb, ids)[[12]]
#> [1]  3  4 10 13 15 16 17 18 19