get_situas_tables.RdRetrieves territorial unit data from the SITUAS (Sistema Informativo Territoriale delle Unità Amministrative e Statistiche) API. The function implements intelligent caching to minimize API calls and enable offline use. Cached data is stored locally and can be refreshed as needed.
This is a convenience wrapper around situas_get_report_data that
provides caching functionality and defaults to retrieving the municipalities
list (report ID 61).
get_situas_tables(
pfun = 61,
date = Sys.Date(),
date_end = NULL,
force_refresh = FALSE,
max_age_hours = 24,
verbose = TRUE
)Integer. Report ID to retrieve. Defaults to 61 (municipalities list).
See list_available_reports for all available reports.
Date, POSIXct, or character string. The reference date for the report. For DATA type reports, this is the single date parameter. For PERIODO/ATTUALIZZAZIONE type reports, this is the start date. Defaults to current date.
Date, POSIXct, or character string. End date for PERIODO and
ATTUALIZZAZIONE type reports. Required for these report types, ignored for
DATA type reports. Default is NULL.
Logical. If TRUE, bypass cache and download fresh
data from the API. If FALSE (default), use cached data if valid.
Numeric. Maximum age of cache in hours before automatic
refresh. Default is 24 hours. Ignored if force_refresh = TRUE.
Logical. If TRUE (default), print informative messages
about cache status and download progress.
A data.table containing the requested report data. The structure
depends on the report ID requested. For the default municipalities report
(ID 61), it includes columns such as:
Geographic partition code
Region code
Province/UTS code
Municipality code (numeric)
Municipality code (text)
Municipality name
Region name
Province/UTS name
Car registration code
Cadastral code
Get Available SITUAS Tables
Downloads the list of available territorial units from the SITUAS API. This function uses caching to enable offline use and reduce unnecessary API calls. By default, it retrieves the municipalities list (report ID 61).
if (FALSE) { # \dontrun{
# Get current municipalities list using cache if available
municipalities <- get_situas_tables()
# Force refresh from API
municipalities <- get_situas_tables(force_refresh = TRUE)
# Get municipalities as of a specific date
municipalities_2020 <- get_situas_tables(date = as.Date("2020-01-01"))
# Get provinces instead of municipalities
provinces <- get_situas_tables(pfun = 64)
# Get municipality changes over a period (PERIODO type report)
changes <- get_situas_tables(
pfun = 99,
date = as.Date("2020-01-01"),
date_end = as.Date("2025-01-01")
)
# Use cached data up to 48 hours old
municipalities <- get_situas_tables(max_age_hours = 48)
# Suppress messages
municipalities <- get_situas_tables(verbose = FALSE)
} # }