| Title: | Identification and Visualisation of European NUTS Regions from Geolocations |
|---|---|
| Description: | Provides functions to identify European NUTS (Nomenclature of Territorial Units for Statistics) regions for geographic coordinates (latitude/longitude) using Eurostat geospatial boundaries. Includes map-based visualisation of the matched regions for validation and exploration. Designed for regional data analysis, reproducible workflows, and integration with common geospatial R packages. |
| Authors: | Attila I. Katona [aut, cre], Marcell T. Kurbucz [aut] |
| Maintainer: | Attila I. Katona <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.1 |
| Built: | 2026-05-17 09:00:18 UTC |
| Source: | https://github.com/aikatona/geonuts |
Vectorised identification of NUTS regions for input coordinates using
Eurostat geospatial layers. Supports a single level (0–3) or "all" to
return all levels. Optional country pre-filter and "nearest" fallback make
the function robust to points falling just outside polygon boundaries.
get_nuts( latitude, longitude, level = "all", year = 2021, resolution = 20, crs = 4326, country = NULL, match_strategy = c("within", "nearest"), nearest_max_km = Inf, verbose = TRUE )get_nuts( latitude, longitude, level = "all", year = 2021, resolution = 20, crs = 4326, country = NULL, match_strategy = c("within", "nearest"), nearest_max_km = Inf, verbose = TRUE )
latitude |
(numeric, mandatory) Latitudes in decimal degrees (WGS84).
Must be within |
longitude |
(numeric, mandatory) Longitudes in decimal degrees (WGS84).
Must be within |
level |
(integer or character, optional) One of |
year |
(integer, optional) NUTS reference year for the Eurostat layer.
Default: |
resolution |
(integer, optional) Eurostat map resolution. Typical
values: |
crs |
(integer, optional) EPSG code of input coordinates. If not 4326,
inputs are transformed to WGS84 (EPSG:4326). Default: |
country |
(character, optional) Two-letter |
match_strategy |
(character, optional) Matching strategy:
|
nearest_max_km |
(numeric, optional) Maximum distance (km) for
nearest fallback; use |
verbose |
(logical, optional) Print informative messages. Default: |
Geometries are downloaded via eurostat::get_eurostat_geospatial() and
cached per (level, year, resolution) to avoid repeated I/O.
Polygons are pre-filtered using the points' bounding box to accelerate joins on continental layers (with safe fallback).
Nearest distances are computed with units and converted to kilometers.
If level is a single integer: a data.frame with columns
lat, lon, nuts, cntr_code, match_status, match_dist_km, level, year, resolution.
If level = "all": a data.frame with
lat, lon, nuts0, nuts1, nuts2, nuts3, cntr_code, match_status, match_dist_km, year, resolution.
Here match_status/match_dist_km are computed using level 3 (most granular).
res <- get_nuts(52.52, 13.405, level = 3, year = 2021, resolution = 20) head(res)res <- get_nuts(52.52, 13.405, level = 3, year = 2021, resolution = 20) head(res)
Visualises the frequency of matched NUTS regions and (optionally) overlays
the input points (matched vs. unmatched) for validation. Works with both
single-level and multi-level (level = "all") outputs from get_nuts.
map_nuts( nuts, map_level = 3, country = NULL, show_points = TRUE, border_col = "lightgrey", low_col = "lightgreen", high_col = "darkgreen", id_col = "black", uid_col = "red", verbose = TRUE )map_nuts( nuts, map_level = 3, country = NULL, show_points = TRUE, border_col = "lightgrey", low_col = "lightgreen", high_col = "darkgreen", id_col = "black", uid_col = "red", verbose = TRUE )
nuts |
(data.frame, mandatory) Output of |
map_level |
(integer, optional) NUTS level to display when multiple
levels are present. One of |
country |
(character, optional) Two-letter |
show_points |
(logical, optional) Overlay input points. Default: |
border_col |
(character, optional) Polygon border colour. Default: |
low_col |
(character, optional) Fill colour for lower frequencies. Default: |
high_col |
(character, optional) Fill colour for higher frequencies. Default: |
id_col |
(character, optional) Point colour for matched/nearest inputs. Default: |
uid_col |
(character, optional) Point colour for unmatched inputs. Default: |
verbose |
(logical, optional) Print informative messages. Default: |
A ggplot2 object showing a choropleth of NUTS frequencies with
optional point overlays.
res <- get_nuts(52.52, 13.405, level = 3, year = 2021, resolution = 20) p <- map_nuts(res, map_level = 3) print(p)res <- get_nuts(52.52, 13.405, level = 3, year = 2021, resolution = 20) p <- map_nuts(res, map_level = 3) print(p)