nbstat: Calculate Neighbourhood Statistics from Polygons

nbstatR Documentation

Calculate Neighbourhood Statistics from Polygons

Description

Calculating descriptive neighbourhood statistics based on regions (polygons) with contiguous boundaries from an object of class nbmatrix

Usage

nbstat(
  object,
  link_data,
  ID_col,
  data_col,
  func = "sum",
  verbose = FALSE
  )

Arguments

object

nbmatrix object

link_data

data.frame to merge with

ID_col

Column with unique ID of each polygon feature in the link_data data.frame

data_col

Column with regarded numeric values in data.frame

func

Descriptive statistic (FUN) to be computed for data_col of the neighbouring regions

verbose

bool argument which indicates whether progress messages are displayed

Details

Calculates a specified statistic (e.g., mean or sum) for the neighboring regions within a nbmatrix object. The user must specify a (spatial) data frame with the parameter link_data. The results are saved in the nbmatrix object. If func is set to NULL, nbstat is used to specify the data column used for further analyses (e.g., moran()).

Value

object of class nbmatrix-class

Author(s)

Thomas Wieland

References

Cliff AD, Ord JK (1981) Spatial Processes: Models & Applications. https://archive.org/details/spatialprocesses0000clif

GeoDa Center (2026) GeoDa. An Introduction to Spatial Data Science. https://geodacenter.github.io/

Wieland T (2020) Flatten the Curve! Modeling SARS-CoV-2/COVID-19 Growth in Germany at the County Level. REGION 7(2), 43–83. \Sexpr[results=rd]{tools:::Rd_expr_doi("https://doi.org/10.18335/region.v7i2.324")}

Wieland T (2022) Spatial patterns of excess mortality in the first year of the COVID-19 pandemic in Germany. European Journal of Geography 13(4), 18-33. \Sexpr[results=rd]{tools:::Rd_expr_doi("https://doi.org/10.48088/ejg.t.wie.13.4.018.033")}

See Also

nbmatrix, moran, getisord, gstar

Examples

data(RKI_Corona_counties)
# German counties (Source: Robert Koch Institute)

Corona_nbmat <- 
  nbmatrix (
    RKI_Corona_counties, 
    ID_col="AGS",
    verbose = TRUE
  )
# Creating neighborhood matrix

Corona_nbstat <- nbstat(
  Corona_nbmat,
  link_data = RKI_Corona_counties, 
  ID_col = "AGS", 
  data_col = "EWZ", 
  func = "sum",
  verbose = TRUE
  )
# Sum of population (EWZ) of neighboring counties

plot(
  Corona_nbstat,
  main = "No. of inhabitants"
  )
# Plot simple map of "EWZ"

swash documentation built on Oct. 18, 2026, 5:06 p.m.