geonuts: Identify and Visualise European NUTS Regions

Overview

The geonuts package provides simple tools to identify European NUTS regions (Nomenclature of Territorial Units for Statistics) based on geographic coordinates, and to visualise the results on a map. It builds on Eurostat’s geospatial layers via eurostat and giscoR.

1. Identify NUTS regions

library(geonuts)

# Example coordinates for European capitals
lat <- c(52.5200, 48.8566, 41.9028)
lon <- c(13.4050,  2.3522, 12.4964)

# Identify NUTS regions (all levels)
nuts_all <- get_nuts(
  latitude = lat,
  longitude = lon,
  level = "all",
  year = 2021,
  resolution = 20,
  verbose = FALSE
)

nuts_all
#>       lat     lon nuts0 nuts1 nuts2 nuts3 cntr_code match_status match_dist_km
#> 1 52.5200 13.4050    DE   DE3  DE30 DE300        DE      matched            NA
#> 2 48.8566  2.3522    FR   FR1  FR10 FR101        FR      matched            NA
#> 3 41.9028 12.4964    IT  <NA>  <NA>  <NA>        IT    unmatched            NA
#>   year resolution
#> 1 2021         20
#> 2 2021         20
#> 3 2021         20

2. Visualise NUTS regions

# Create a map for the most granular (NUTS3) level
map_nuts(nuts_all, map_level = 3, show_points = TRUE)
#> [geonuts] Using cached NUTS layer.
#> [geonuts] Rendered map: level=3, year=2021, resolution=20.

You can also filter the map to a single country:

map_nuts(nuts_all, map_level = 3, country = "IT")
#> [geonuts] Using cached NUTS layer.
#> [geonuts] Rendered map: level=3, year=2021, resolution=20, country=IT.

3. Single-level example

If you only need one level (e.g., NUTS2):

nuts2 <- get_nuts(lat, lon, level = 2, year = 2021, resolution = 20)
#> [geonuts] Using cached NUTS layer.
#> [geonuts] Matched level 2.
head(nuts2)
#>       lat     lon nuts cntr_code match_status match_dist_km level year
#> 1 52.5200 13.4050 DE30        DE      matched            NA     2 2021
#> 2 48.8566  2.3522 FR10        FR      matched            NA     2 2021
#> 3 41.9028 12.4964 <NA>      <NA>    unmatched            NA     2 2021
#>   resolution
#> 1         20
#> 2         20
#> 3         20

4. Working offline and caching

Eurostat layers are cached automatically by eurostat and giscoR, so once downloaded, subsequent calls to get_nuts() and map_nuts() are offline-safe and much faster.

To clear cached shapefiles manually:

unlink(tools::R_user_dir("eurostat", "cache"), recursive = TRUE)

Summary

Function Purpose
get_nuts() Identify NUTS regions from latitude–longitude pairs
map_nuts() Visualise NUTS regions and matched points on a map