Learn R Programming

mapSpain (version 0.1.2)

esp_get_gridmap: Get an hexbin or a map of squares of Spain

Description

Loads a hexbin map (sf object) or a map of squares with the boundaries of the provinces or autonomous communities of Spain.

Usage

esp_get_hex_prov(prov = NULL)

esp_get_hex_ccaa(ccaa = NULL)

esp_get_grid_prov(prov = NULL)

esp_get_grid_ccaa(ccaa = NULL)

Arguments

prov
ccaa

Value

A POLYGON object.

Details

Hexbin or grid map has an advantage over usual choropleth maps. In choropleths, a large polygon data looks more emphasized just because of its size, what introduces a bias. Here with hexbin, each region is represented equally dismissing the bias.

Results are provided in EPSG:4258, use st_transform to change the projection.

See Also

esp_get_nuts, esp_get_ccaa, esp_get_prov, esp_get_munic, esp_codelist

Examples

Run this code
# NOT RUN {
library(sf)
library(cartography)

esp <- st_transform(esp_get_country(), 3857)

hexccaa <- st_transform(esp_get_hex_ccaa(), 3857)

plot_sf(hexccaa)
plot(st_geometry(esp),
     col = "grey80",
     border = NA,
     add = TRUE)
plot(st_geometry(hexccaa),
     col = hcl.colors(19, alpha = 0.5),
     add = TRUE)
labelLayer(hexccaa, txt = "label")



hexprov <- st_transform(esp_get_hex_prov(), 3857)

plot_sf(hexprov)
plot(st_geometry(esp),
     col = "grey80",
     border = NA,
     add = TRUE)
plot(st_geometry(hexprov),
     col = hcl.colors(19, alpha = 0.5),
     add = TRUE)
labelLayer(hexprov, txt = "label")



gridccaa <- st_transform(esp_get_grid_ccaa(), 3857)

plot_sf(gridccaa)
plot(st_geometry(esp),
     col = "grey80",
     border = NA,
     add = TRUE)
plot(st_geometry(gridccaa),
     col = hcl.colors(19, alpha = 0.5),
     add = TRUE)
labelLayer(gridccaa, txt = "label")

gridprov <- st_transform(esp_get_grid_prov(), 3857)

plot_sf(gridprov)
plot(st_geometry(esp),
     col = "grey80",
     border = NA,
     add = TRUE)
plot(st_geometry(gridprov),
     col = hcl.colors(19, alpha = 0.5),
     add = TRUE)
labelLayer(gridprov, txt = "label")
# }

Run the code above in your browser using DataLab