add_geodata: Adding Geodata to Infpan Object

add_geodataR Documentation

Adding Geodata to Infpan Object

Description

Assigns geodata (sf object) to an infpan object.

Usage

add_geodata(
    object,
    sf_geodata,
    unit_col,
    verbose = FALSE
  )

Arguments

object

object of class infpan

sf_geodata

sf object containing features (polygons) representing the study area (e.g., counties)

unit_col

Unique ID column of the regions in the sf object

verbose

bool argument which indicates whether progress messages are displayed

Details

Adds geodata (sf object) to the infpan object. Included geodata is mandatory for plotting indicators via plot_map.

Value

Input infpan object including geodata

Author(s)

Thomas Wieland

References

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")}

See Also

infpan-class, load_infections_paneldata, calculate_incidence, calculate_cum, calculate_rollmean, calculate_rollsum, calculate_Rt

Examples

data(COVID19Cases_geoRegion)
# Get SWISS COVID19 cases at NUTS 3 level

data(K4kant20260101gf_ch2007Poly)
# Cantonal boundaries of Switzerland

COVID19Cases_geoRegion <- 
  COVID19Cases_geoRegion[!COVID19Cases_geoRegion$geoRegion %in% c("CH", "CHFL"),]
# Exclude CH = Switzerland total and CHFL = Switzerland and Liechtenstein total

COVID19Cases_geoRegion <- 
  COVID19Cases_geoRegion[COVID19Cases_geoRegion$datum <= "2020-05-31",]
# Extract first COVID-19 wave

infpan_CH <- load_infections_paneldata(
    data = COVID19Cases_geoRegion,
    col_cases = "entries",
    col_date = "datum",
    col_region = "geoRegion",
    other_cols = c("Population" = "pop"), 
    verbose = TRUE
  )
# Import as infections panel data set (class infpan)

infpan_CH <- calculate_incidence(
  infpan_CH, 
  col_name = "incidence",
  verbose = TRUE
)
# Calculate incidence of cases as "incidence"

infpan_CH <- add_geodata(
  infpan_CH,
  K4kant20260101gf_ch2007Poly,
  unit_col = "cant_abbrev"
)
# Adding geodata (sf) to infpan object

summary(infpan_CH)
# Summary of infpan object

timestamps(infpan_CH)
# Time stamps of infpan object

plot_map(
  infpan_CH,
  attribute = "Incidence",
  main = "COVID-19 Incidence 2020-05-31",
  breaks = c(0, 0.05, 0.1, 0.2, 1),
  verbose = TRUE
)
# Simple map of incidence for the most current date (timepoint=NULL)

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