download_istat_boundaries.RdDownloads generalized boundary shapefiles for Italian administrative units from the OnData repository (with ISTAT fallback). Boundaries are cached locally for offline use.
download_istat_boundaries(
date = NULL,
territorial_levels = c("comuni", "province", "regioni", "ripartizioni"),
output_dir = NULL,
force_refresh = FALSE,
verbose = TRUE
)Date for which to download boundaries. Can be a Date object or character string in "YYYY-MM-DD" format. Defaults to most recent January 1st. Available dates: January 1st of each year from 2020 to present.
Character vector of territorial levels to download. Options: "comuni", "province", "regioni", "ripartizioni". Default is all levels.
Directory where boundaries will be cached. Default uses
tools::R_user_dir("situas", which = "data").
Logical. If TRUE, re-downloads even if already cached. Default is FALSE.
Logical. Print progress messages? Default is TRUE.
A data.table with download status for each territorial level, including:
territorial_level: The territorial level
status: "success", "cached", or "failed"
source: "OnData" or "ISTAT"
file_path: Path to downloaded shapefile
error: Error message if status is "failed"
Primary source is the OnData repository (https://www.confini-amministrativi.it), which provides ISTAT boundaries in multiple formats with easier programmatic access. If OnData is unavailable, the function falls back to direct ISTAT downloads.
Downloaded boundaries are organized by date:
{cache_dir}/boundaries/
├── 20250101/
│ ├── Com_gen_WGS84.shp
│ ├── ProvCM_gen_WGS84.shp
│ └── ...
└── metadata.rds
list_istat_boundary_versions to see available versions
check_boundary_updates to check for updates
get_cached_boundaries_info to see cached boundaries
if (FALSE) { # \dontrun{
# Download all boundaries for 2025-01-01
result <- download_istat_boundaries()
# Download only municipalities for a specific date
result <- download_istat_boundaries(
date = "2024-01-01",
territorial_levels = "comuni"
)
# Force re-download even if cached
result <- download_istat_boundaries(force_refresh = TRUE)
} # }