Downloads 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
)

Arguments

date

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.

territorial_levels

Character vector of territorial levels to download. Options: "comuni", "province", "regioni", "ripartizioni". Default is all levels.

output_dir

Directory where boundaries will be cached. Default uses tools::R_user_dir("situas", which = "data").

force_refresh

Logical. If TRUE, re-downloads even if already cached. Default is FALSE.

verbose

Logical. Print progress messages? Default is TRUE.

Value

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"

Data Source

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.

File Organization

Downloaded boundaries are organized by date:


{cache_dir}/boundaries/
  ├── 20250101/
  │   ├── Com_gen_WGS84.shp
  │   ├── ProvCM_gen_WGS84.shp
  │   └── ...
  └── metadata.rds

See also

list_istat_boundary_versions to see available versions check_boundary_updates to check for updates get_cached_boundaries_info to see cached boundaries

Examples

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