Skip to contents

Get comarcas of Spain. Comarcas are traditional informal territorial divisions comprising several municipalities that share geographical, economic or cultural traits, typically with poorly defined limits.

Usage

esp_get_comarca(
  region = NULL,
  comarca = NULL,
  moveCAN = TRUE,
  type = c("INE", "IGN", "AGR", "LIV"),
  epsg = 4258,
  update_cache = FALSE,
  cache_dir = NULL,
  verbose = FALSE
)

Source

INE: PC_Axis files, IGN, Ministry of Agriculture, Fisheries and Food (MAPA).

Arguments

region

Character string. A vector of names, codes or both for provinces, or NULL to get all the comarcas. See Details.

comarca

Character string. A name or regex expression with the names of the required comarcas. Use NULL to return all possible comarcas.

moveCAN

A logical TRUE/FALSE or a vector of coordinates c(lat, lon). It places the Canary Islands close to Spain's mainland. Initial position can be adjusted using the vector of coordinates. See Displacing the Canary Islands in esp_move_can().

type

Character string. One of "INE", "IGN", "AGR", "LIV". Type of comarca to return. See Details.

epsg

Character string or number. Projection of the map: 4-digit EPSG code. One of:

update_cache

Logical. If TRUE, refreshes the cached file and forces a new download. Defaults to FALSE.

cache_dir

Character string. A path to a cache directory. See Caching strategies section in esp_set_cache_dir().

verbose

logical. If TRUE displays informational messages.

Value

A sf object.

Details

When using region you can use and mix names and NUTS codes (levels 1, 2 or 3), ISO codes (corresponding to level 2 or 3) or "cpro" (see esp_codelist).

When calling a higher level (province, Autonomous Community or City, or NUTS 1), all comarcas of that level are added.

Note

The use of the information contained on the INE website may be carried out by users or re-use agents, at their own risk, and they will be the sole liable parties in the case of having to answer to third parties due to damages arising from such use.

About comarcas

Comarcas (English equivalent: district, county, area or zone) do not always have a formal legal status. They correspond mainly to natural areas (valleys, river basins and similar areas), historical regions or ancient kingdoms.

In the case of Spain, comarcas only have an administrative character legally recognized in Catalonia, the Basque Country, Navarra (named merindades instead), the region of El Bierzo (Castilla y Leon) and Aragon. Galicia, the Principality of Asturias and Andalusia have functional comarcas.

Types

esp_get_comarca() can retrieve several types of comarcas, each provided under different classification criteria.

  • "INE": Comarcas defined by the National Statistics Institute (INE).

  • "IGN": Official comarcas, only available for some Autonomous Communities and Cities, provided by the National Geographic Institute.

  • "AGR": Agrarian comarcas defined by the Ministry of Agriculture, Fisheries and Food (MAPA).

  • "LIV": Livestock comarcas defined by the Ministry of Agriculture, Fisheries and Food (MAPA).

Examples

# \donttest{
comarcas <- esp_get_comarca(moveCAN = FALSE)

library(ggplot2)

ggplot(comarcas) +
  geom_sf()


# IGN provides recognized comarcas.

rec <- esp_get_comarca(type = "IGN")

ggplot(rec) +
  geom_sf(aes(fill = t_comarca))


# Legal comarcas of Catalunya.

comarcas_cat <- esp_get_comarca("Catalunya", type = "IGN")

ggplot(comarcas_cat) +
  geom_sf(aes(fill = ine.prov.name)) +
  labs(fill = "Province")

# }