General-purpose choropleth: joins a tidy indicator tibble (keyed by
GEOID, matching get_ine_geo()'s output — e.g. get_ine_demog()'s
output already has it) onto province or municipality geometry and
renders it, either as a binned/discrete-legend map (the default,
matching the classic "N provinces above/below a threshold" style of
choropleth) or a continuous gradient. map_life_expectancy() is a
thin wrapper around this function for System B's life-table output.
map_indicator(
df,
value_col,
geo_level = c("province", "municipality"),
region = NULL,
binned = TRUE,
breaks = NULL,
palette = if (binned) "PiYG" else "D",
moveCAN = TRUE,
can_gap_km = 60,
legend_title = NULL,
title = NULL
)A tibble with a GEOID column (matching get_ine_geo()'s
GEOID for the requested geo_level) and value_col.
Character, the name of the numeric column to map.
Character, one of "province" or "municipality".
Optional character vector to subset the geometry by
region name (regular expressions allowed). See get_ine_geo().
Logical (default TRUE). If TRUE, uses a discrete,
binned color scale (ggplot2::scale_fill_fermenter()) — a fixed
number of color bands with a legend showing each band's range,
matching the classic choropleth style. If FALSE, uses a continuous
gradient (ggplot2::scale_fill_viridis_c() by default).
Numeric vector of bin edges when binned = TRUE. If
NULL (default), computed automatically via pretty().
Character, a RColorBrewer palette name when
binned = TRUE (default "PiYG", a pink-to-green diverging
palette well suited to ratios centered on 1) or a viridis option
letter when binned = FALSE (default "D").
Logical, shift the Canary Islands next to the mainland
(default TRUE). See get_ine_geo().
Numeric, gap in km for the shifted Canary Islands
(default 60). See get_ine_geo().
Optional legend title (defaults to value_col).
Optional plot title.
A ggplot object.
if (FALSE) { # \dontrun{
# Not run: get_ine_geo() requires live network access to fetch boundaries.
pop_data <- get_ine_demog(indicator = "population_total", year = 2023)
map_indicator(pop_data, "population_total", geo_level = "province")
} # }