Skip to content

Norwegian NUTS 3 codes in recent cross walks #7

Description

@AAoritz

Verify this inconsistency:

# Install R package with most recent transition matrices
library(remotes)
install_github("rOpenSci/nuts")
#> Using GitHub PAT from the git credential store.
#> Skipping install of 'nuts' from a github remote, the SHA1 (6ceba812) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(nuts)
#> If you use this package in your work, please support the development of open science by citing:
#> 
#> Hennicke M, Krause W (2024). nuts: Convert European Regional Data. doi:10.5281/zenodo.10573056, R package version 1.1.0, <https://docs.ropensci.org/nuts/>

library(tidyverse)
library(remotes)
library(janitor)
#> 
#> Attaching package: 'janitor'
#> The following objects are masked from 'package:stats':
#> 
#>     chisq.test, fisher.test
library(sf)
#> Linking to GEOS 3.12.2, GDAL 3.11.3, PROJ 9.4.1; sf_use_s2() is TRUE
library(giscoR)

# Load cross_walk from nuts package
data("cross_walks")

# Download all shapefiles for NUTS 3 regions
res = "20"
versions <- cross_walks %>%
  distinct(from_version) %>%
  pull(from_version)
versions
#> [1] "2006" "2010" "2013" "2016" "2021" "2024"
eu_3_maps  <- map(
  versions,
  \(x)
  gisco_get_nuts(
    nuts_level = 3,
    epsg = "3857",
    resolution = res,
    year = x
  ) %>%
    clean_names() %>% mutate(from_version = x)
)
names(eu_3_maps) <- versions

# Build names
nuts_names <- map(
  eu_3_maps,
  \(x) x %>%
    st_set_geometry(NULL) %>%
    select(geo, nuts_name, name_latn, from_version)
) %>%
  bind_rows() %>%
  as_tibble() %>%
  rename(code = geo) %>%
  arrange(code)

# Sanity checks
#================
# Check if transition matrix NUTS 3 regions are inside shapefiles
# There are some unmatched geometries for Norway
cross_walks %>%
  filter(level == 3) %>%
  anti_join(nuts_names, by = c("from_code" = "code", "from_version"))
#> # A tibble: 20 × 12
#>    from_code to_code from_version to_version level country  areaKm  pop21  pop11
#>    <chr>     <chr>   <chr>        <chr>      <dbl> <chr>     <dbl>  <dbl>  <dbl>
#>  1 ELZZZ     ELZZZ   2013         2013           3 Greece   3.36e2   1652 1.67e3
#>  2 ELZZZ     ELZZZ   2013         2016           3 Greece   3.36e2   1652 1.67e3
#>  3 NO061     NO053   2016         2006           3 Norway   7.99e0      0 2.5 e0
#>  4 NO061     NO061   2016         2006           3 Norway   1.81e4 320518 2.83e5
#>  5 NO062     NO061   2016         2006           3 Norway   6.21e2   6476 6.34e3
#>  6 NO062     NO062   2016         2006           3 Norway   2.23e4 135454 1.29e5
#>  7 NO061     NO061   2016         2010           3 Norway   1.81e4 320518 2.83e5
#>  8 NO062     NO061   2016         2010           3 Norway   6.21e2   6476 6.33e3
#>  9 NO062     NO062   2016         2010           3 Norway   2.23e4 135454 1.29e5
#> 10 ELZZZ     ELZZZ   2016         2013           3 Greece   3.36e2   1652 1.67e3
#> 11 NO061     NO061   2016         2013           3 Norway   1.81e4 320518 2.83e5
#> 12 NO062     NO061   2016         2013           3 Norway   6.21e2   6476 6.33e3
#> 13 NO062     NO062   2016         2013           3 Norway   2.23e4 135454 1.29e5
#> 14 ELZZZ     ELZZZ   2016         2016           3 Greece   3.36e2   1652 1.67e3
#> 15 NO061     NO061   2016         2016           3 Norway   1.81e4 320518 2.83e5
#> 16 NO062     NO062   2016         2016           3 Norway   2.29e4 141930 1.35e5
#> 17 NO061     NO060   2016         2021           3 Norway   1.81e4 320518 2.83e5
#> 18 NO062     NO060   2016         2021           3 Norway   2.29e4 141930 1.35e5
#> 19 NO061     NO060   2016         2024           3 Norway   1.81e4 320518 2.83e5
#> 20 NO062     NO060   2016         2024           3 Norway   2.29e4 141930 1.35e5
#> # ℹ 3 more variables: artif_surf18 <dbl>, artif_surf12 <dbl>, bu_vol <dbl>

Created on 2025-09-01 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions