Introduction
The full site with more examples and vignettes is available at https://ropengov.github.io/giscoR/.
giscoR downloads geospatial datasets from Eurostat’s GISCO geodata distribution.
GISCO provides geospatial data for the European Union, its member states and subnational regions. Its global datasets include country boundaries, labels and coastal lines.
For compatible administrative and statistical datasets, use 01M or 03M for more detail and 10M, 20M or 60M for broader views. Available coordinate reference systems include EPSG:4326, EPSG:3035 and EPSG:3857. Grid, transport and basic service datasets use the formats and coordinate reference systems documented for each dataset.
giscoR returns sf objects. See https://r-spatial.github.io/sf/ for details.
Caching
giscoR supports caching downloaded datasets. Set the cache directory with:
gisco_set_cache_dir("./path/to/location")With caching enabled, giscoR downloads files missing from the cache and reuses them on subsequent requests.
If downloading fails, you can manually download the file from the GISCO geodata distribution and place it in your local cache directory.
Downloading data
Review the following attribution and licensing requirements before using GISCO data:
General copyright
Eurostat’s general copyright notice and license policy applies. Some datasets have additional download and usage provisions. The download and use of these data are subject to acceptance of those provisions. See the administrative units and statistical units, grids and basic services for more details, including source-specific conditions.
Population grids
gisco_get_grid() downloads polygon or cell-center point GeoPackages in EPSG:3035 at resolutions from 1 km to 100 km. Population columns use names such as TOT_P_2021. To calculate people per square kilometer, divide the population count by the cell area in square kilometers (resolution^2). Population variables have year- and country-specific licensing conditions. Consult the official grid documentation before publication or redistribution.
gisco_attributions() returns attribution text for administrative boundaries in several languages.
library(giscoR)
c(
gisco_attributions(lang = "en"),
gisco_attributions(lang = "fr"),
gisco_attributions(lang = "de")
) |> cat(sep = "\n\n")
#> © EuroGeographics for the administrative boundaries
#>
#> © EuroGeographics pour les limites administratives
#>
#> © EuroGeographics bezüglich der VerwaltungsgrenzenBasic example
This example downloads the 2024 world country dataset and highlights EU member states and candidate countries.
library(dplyr)
library(ggplot2)
world <- gisco_get_countries(resolution = 3, epsg = 3035)
world <- world |>
mutate(
status = case_when(
EU_STAT == "T" ~ "Current members",
CC_STAT == "T" ~ "Candidate countries",
TRUE ~ NA
),
# Set levels.
status = factor(status,
levels = c("Current members", "Candidate countries")
)
)
ggplot(world) +
geom_sf(fill = "#c1c1c1") +
geom_sf(aes(fill = status), color = "white") +
guides(fill = guide_legend(direction = "horizontal")) +
# Center on Europe with EPSG 3035.
coord_sf(
xlim = c(2377294, 7453440),
ylim = c(1313597, 5628510)
) +
scale_fill_manual(
values = c("#039", "#2782bb"), na.value = "#c1c1c1",
na.translate = FALSE
) +
theme_minimal() +
theme(
panel.background = element_rect(fill = "grey90", color = NA),
axis.line = element_blank(),
axis.text = element_blank(),
panel.grid = element_blank(),
legend.position = "bottom"
) +
labs(
title = "EU member states and candidate countries (2024)",
caption = gisco_attributions(),
fill = ""
)
EU member states and candidate countries (2024)
Use country to select specific countries by name, ISO 3166-1 alpha-3 code or Eurostat code.
This example overlays North African countries and coastal lines using the same resolution and epsg. To compare datasets for a particular year, use the same year when it is available for both.
cntr <- c("Morocco", "Algeria", "Tunisia", "Libya", "Egypt")
africa_north <- gisco_get_countries(
country = cntr,
resolution = "03",
epsg = "4326", year = "2024"
)
# Order plot facets.
africa_north$NAME_ENGL <- factor(africa_north$NAME_ENGL, levels = cntr)
# Get coastal lines.
coast <- gisco_get_coastal_lines(
resolution = "03",
epsg = "4326",
year = "2016"
)
# Create plot.
ggplot(coast) +
geom_sf(color = "#B9B9B9") +
geom_sf(data = africa_north, fill = "#346733", color = "#335033") +
coord_sf(xlim = c(-13, 37), ylim = c(18.5, 40)) +
facet_wrap(vars(NAME_ENGL), ncol = 2) +
labs(caption = gisco_attributions("fr"))
Political map of North Africa
Thematic maps with giscoR
This example maps 2021 net disposable household income per inhabitant using Eurostat data, 2021 NUTS 2 regions and ggplot2. You can also use tmap, mapsf, leaflet or other packages that support sf objects.
# Load EU member data.
library(giscoR)
library(dplyr)
library(eurostat)
library(ggplot2)
nuts2 <- gisco_get_nuts(
year = "2021", epsg = "3035", resolution = "10",
nuts_level = "2"
)
# Get country borders from the same NUTS release.
borders <- gisco_get_nuts(
year = "2021", epsg = "3035", resolution = "10",
nuts_level = "0"
)
eu_bord <- borders |>
filter(CNTR_CODE %in% nuts2$CNTR_CODE)
# Retrieve net disposable income per inhabitant from Eurostat.
pps <- get_eurostat(
"nama_10r_2hhinc",
filters = list(
time = "2021",
na_item = "B6N",
direct = "BAL",
unit = "PPS_EU27_2020_HAB"
),
verbose = FALSE
) |>
select(geo, values)
nuts2_sf <- nuts2 |>
left_join(pps, by = "geo") |>
mutate(
pps_thousands = values / 1000,
categ = cut(
pps_thousands,
breaks = c(-Inf, 10, 15, 20, 25, Inf),
labels = c("< 10", "10–<15", "15–<20", "20–<25", "≥ 25"),
right = FALSE
)
)
# Create the plot.
ggplot(nuts2_sf) +
# Add background geometry.
geom_sf(data = borders, fill = "#e1e1e1", color = NA) +
geom_sf(aes(fill = categ), color = "grey20", linewidth = .1) +
geom_sf(data = eu_bord, fill = NA, color = "black", linewidth = .15) +
# Center on Europe with EPSG 3035.
coord_sf(xlim = c(2377294, 6500000), ylim = c(1413597, 5228510)) +
# Configure legends and color.
scale_fill_manual(
values = hcl.colors(nlevels(nuts2_sf$categ), "Geyser", rev = TRUE),
# Label missing values.
labels = function(x) {
ifelse(is.na(x), "No data", x)
},
na.value = "#e1e1e1"
) +
guides(fill = guide_legend(nrow = 1)) +
theme_void() +
theme(
text = element_text(colour = "grey0"),
panel.background = element_rect(fill = "#97dbf2"),
panel.border = element_rect(fill = NA, color = "grey10"),
plot.title = element_text(hjust = 0.5, vjust = -1, size = 12),
plot.subtitle = element_text(
hjust = 0.5, vjust = -2, face = "bold",
margin = margin(b = 10, t = 5), size = 12
),
plot.caption = element_text(
size = 8, hjust = 0, margin =
margin(b = 4, t = 8)
),
legend.text = element_text(size = 7, ),
legend.title = element_text(size = 7),
legend.position = "bottom",
legend.direction = "horizontal",
legend.text.position = "bottom",
legend.title.position = "top",
legend.key.height = rel(0.5),
legend.key.width = unit(0.1, "npc")
) +
# Add labels.
labs(
title = "Net disposable household income per inhabitant (2021)",
subtitle = "NUTS 2 level",
fill = "PPS per inhabitant (thousands)",
caption = paste0(
"Source: Eurostat, ", gisco_attributions()
)
)
Net disposable household income per inhabitant by NUTS 2 region (2021)
Use these examples as a starting point for your own maps.
