Skip to contents

Downloads and extracts census tract boundary files from the ineAtlas repository, returning an sf object with the geometries for the specified year.

Usage

get_tract_geom(year, cache = TRUE, cache_dir = tempdir())

Arguments

year

Numeric. Year of the census tract boundaries to retrieve (2015-2025)

cache

Logical indicating whether to cache the extracted data. Default is TRUE. Cached data is stored uncompressed for faster access.

cache_dir

Character string specifying the cache directory. Default is tempdir().

Value

An sf object containing census tract boundaries with the following columns:

  • year: The reference year

  • tract_code: Census tract identifier

  • municipality: Municipality name

  • province: Province name

  • geometry: Census tract boundary geometry

If the geometries cannot be downloaded and no cached copy is available, returns NULL (invisibly) with an informative message.

Examples

# \donttest{
# Get census tract boundaries for 2020
tracts_2020 <- get_tract_geom(2020)
#> Downloading geometries for 2020...
#> Caching geometries to ineatlas_tracts_2020.gpkg
#> Geometries successfully loaded: 36309 features
# }