Retrieves spatial geometries for INE geographic levels via the mapSpain package, which sources boundaries from Instituto Geografico Nacional / GISCO. Geometries are returned with a GEOID column that matches the geographic codes returned by get_ine_demog(), so the two can be joined directly.

get_ine_geo(
  geo_level = c("municipality", "province"),
  region = NULL,
  moveCAN = TRUE,
  can_gap_km = 60
)

Arguments

geo_level

Character, one of "municipality" or "province".

region

Optional character vector to subset by region name (regular expressions allowed).

moveCAN

Logical, shift the Canary Islands next to the mainland for compact national maps (default TRUE). Pass FALSE to keep their real geographic coordinates.

can_gap_km

Numeric, the gap in kilometers left between the shifted Canary Islands and the closest point on the mainland coast (default 60). Only used when moveCAN = TRUE. Smaller values move the islands closer.

Value

An sf object with columns GEOID, NAME, and geometry, projected to ETRS89 / UTM zone 30N (EPSG:25830). When moveCAN = TRUE and the shift was applied, an sfc rectangle marking the shifted islands' extent is attached as the "can_box" attribute (used by plot_ine_map() to draw an inset frame).

Examples

if (FALSE) { # \dontrun{
# Not run: requires live network access to fetch boundaries via mapSpain.
prov_geo <- get_ine_geo(geo_level = "province")
mun_geo <- get_ine_geo(geo_level = "municipality", region = "Sevilla")
} # }