GitLab at IIASA

translate_Nuts.R 57.2 KiB
Newer Older
Xinxin Yang's avatar
Xinxin Yang committed
# download the lists of changes between the various NUTS versions from: https://ec.europa.eu/eurostat/en/web/nuts/history
# save the excel: D:\data\fadn\lieferung_20210414\yang\fadn_work_space\NUTS
# rm(list=setdiff(ls(), c("str_data","fadn.animal")))

rm (list = ls())
library(tidyverse)
library(data.table)
Xinxin Yang's avatar
Xinxin Yang committed
# nuts2 rules ####
nuts2_transformation = TRUE

if (nuts2_transformation){

# deu ####
deu <- tibble(
NUTS2     = c("DEE1","DEE2","DEE3", "DE41", "DE42", "DED1", "DED3"),
NUTS2_new  = c("DEE0","DEE0","DEE0", "DE40", "DE40", "DED4" ,"DED5"),
regional_surface = 1,
COUNTRY = "DEU"
) %>% mutate(change = case_when(NUTS2_new == "DEE0" ~ "merge",
                                NUTS2_new == "DE40" ~ "merge",
                                NUTS2_new == "DED4" ~ "boundary shift, new region",
                                NUTS2_new == "DED5" ~ "boundary shift, new region",
Xinxin Yang's avatar
Xinxin Yang committed
                                TRUE ~ "recoded"),
from_NUTS3 = '', from_ex_NUTS3 = '', convert = TRUE)
Xinxin Yang's avatar
Xinxin Yang committed
# ell ####
ell <- tibble(
NUTS2     = c("GR11","EL11", "GR12", "EL12","GR13", "EL13", "GR14", "EL14", "GR21", "EL21","GR22", "EL22","GR23", "EL23","GR24", "EL24","GR25", "EL25",
            "GR30","GR41","GR42","GR43"),
NUTS2_new = c(rep("EL51",2), rep("EL52", 2), rep("El53",2), rep("EL54",2), rep("EL61",2),rep("EL62",2), rep("EL63",2),rep("EL64",2),rep("EL65",2),
            "EL30","EL41","EL42","EL43"),
regional_surface = 1,
COUNTRY = "ELL"
) %>% mutate(change = case_when(regional_surface ==1 ~ "recoded"),
             from_NUTS3 = '', from_ex_NUTS3 = '', convert = TRUE)
Xinxin Yang's avatar
Xinxin Yang committed
# fra ####
fra <- read.table(
text =   "NUTS2 NUTS2_new
        FR24	FRB0
        FR26	FRC1
        FR43	FRC2
        FR25	FRD1
        FR23	FRD2
        FR30	FRE1
        FR22	FRE2
        FR42	FRF1
        FR21	FRF2
        FR41	FRF3
        FR51	FRG0
        FR52	FRH0
        FR61	FRI1
        FR63	FRI2
        FR53	FRI3
        FR81	FRJ1
        FR62	FRJ2
        FR72	FRK1
        FR71	FRK2
        FR82	FRL0
        FR83	FRM0
        FRA1	FRY1
        FRA2	FRY2
        FRA3	FRY3
        FRA4	FRY4
        FRA5	FRY5", header =TRUE) %>% as_tibble() %>%
  mutate (COUNTRY = "FRA", regional_surface = 1) %>%
  mutate_if(is.factor, as.character) %>%
  mutate(change = (case_when(regional_surface ==1 ~ "recoded" )),
         from_NUTS3 = '', from_ex_NUTS3 = '', convert = TRUE)
Xinxin Yang's avatar
Xinxin Yang committed
# hun??? ####
# fadn data has no HU11
hun <- read.table(
text =   "NUTS2 NUTS2_new COUNTRY regional_surface
        HU10 HU12 HUN 0.92
        HU10 HU11 HUN 0.08", header = TRUE )  %>%
  as_tibble() %>%
  mutate_if(is.factor, as.character) %>%
  mutate(change = (case_when(NUTS2 =="HU10" ~ "split" )),
         from_NUTS3 = 'fadn data has no HU11', from_ex_NUTS3 = '', convert = FALSE)
Xinxin Yang's avatar
Xinxin Yang committed

# IRE ######
# IE01		discontinued
# IE02		discontinued
# IE04		new region ?????????????????
# IE05	  new region, made from ex-IE023, IE024 and IE025	IE05=IE023+IE024+IE025 (from NUTS3)
# IE06		new region ?????????????????

# old . new  value
#.................
# IE01. IE04 0.78
# IE01. IE06 0.20
Xinxin Yang's avatar
Xinxin Yang committed
# IE02. IE05 0.81
# IE02. IE06 0.42

ire <- read.table(
  text =  "NUTS2 NUTS2_new regional_surface change
  IE01 IE04 0.78 'discontinued, new region'
  IE01 IE06 0.20 'discontinued, new region'
Xinxin Yang's avatar
Xinxin Yang committed
  IE02 IE05 0.81 'discontinued, new region'
  IE02 IE06 0.42 'discontinued, new region' ", header = TRUE ) %>%
  as_tibble() %>%
  mutate (COUNTRY = "IRE", from_NUTS3 = '', from_ex_NUTS3 = '', convert = FALSE) %>%
Xinxin Yang's avatar
Xinxin Yang committed
  mutate_if(is.factor, as.character)

# ita ####
ita <- read.table(
text =  "NUTS2 NUTS2_new regional_surface
      ITD1	ITH1 1
      ITD2	ITH2 1
      ITD3	ITH3 1
      ITD4	ITH4 1
      ITE4	ITI4 1
      ITE1	ITI1 1
      ITE2	ITI2 1
      ITD5  ITH5 1.03
      ITE3  ITI3 0.97", header = TRUE ) %>%
  as_tibble() %>%
  mutate (COUNTRY = "ITA",
          change = (case_when(regional_surface==1 ~ "recoded",
                                             TRUE ~ "boundary shift, recoded")),
Xinxin Yang's avatar
Xinxin Yang committed
          from_NUTS3 = '',
          from_ex_NUTS3 = '', convert = TRUE) %>%
Xinxin Yang's avatar
Xinxin Yang committed
  mutate_if(is.factor, as.character)


# ltu ####
ltu <- read.table(
text =  "NUTS2 NUTS2_new regional_surface from_NUTS3
  LT00  LT01 0.15 LT00A
  LT00  LT02 0.85 'LT00-LT00A'", header = TRUE ) %>%
  as_tibble() %>%
  mutate (COUNTRY = "LTU",
          change = (case_when(regional_surface!=1 ~ "split")),
          from_ex_NUTS3 = '', convert = FALSE) %>%
Xinxin Yang's avatar
Xinxin Yang committed
  mutate_if(is.factor, as.character)
# pol ####
pol <- read.table(
text =  "NUTS2 NUTS2_new regional_surface from_NUTS3 convert
      PL11	PL71 1 '' TRUE
      PL33	PL72 1 '' TRUE
      PL31	PL81 1 '' TRUE
      PL32	PL82 1 '' TRUE
      PL34	PL84 1 '' TRUE
      PL12  PL91 0.17 'PL127+PL129+PL12A-newPL926' FALSE
      PL12  PL92 0.83 'PL128+PL12B+PL12C+PL12D+PL12E+newPL926' FALSE", header = TRUE ) %>%
Xinxin Yang's avatar
Xinxin Yang committed
as_tibble() %>%
mutate (COUNTRY = "POL",
      change = (case_when(regional_surface==1 ~ "recoded", TRUE ~ "split"  )),
      from_ex_NUTS3 = '') %>%
mutate_if(is.factor, as.character)
# suo #####
#     merge     new region
# 1:  FI1A      FI1D      1
# 2:  FI13      FI1D      1
                      0.01
# ...........................
#     split     new region
# 3:  FI18      FI1B      0.21
# 4:  FI18      FI1C      0.78

suo <- read.table(
text =  "NUTS2 NUTS2_new regional_surface convert
FI13	FI1D 1 FALSE
FI1A	FI1D 1 FALSE
FI18  FI1D 0.01 FALSE
FI18  FI1B 0.21 FALSE
FI18  FI1C 0.78 FALSE
Xinxin Yang's avatar
Xinxin Yang committed
", header = TRUE ) %>%
as_tibble() %>%
mutate (COUNTRY = "SUO",
      change = (case_when(NUTS2 %in% c("FI13","FI1A") ~ "merge", TRUE ~ "split"  )),
      from_NUTS3 = '', from_ex_NUTS3 = '') %>%
mutate_if(is.factor, as.character)
# sve ####
sve <- read.table(
text =  "NUTS2 NUTS2_new regional_surface
        SE01	SE11 1
        SE02	SE12 1
        SE09	SE21 1
        SE04	SE22 1
        SE0A	SE23 1
        SE06	SE31 1
        SE07	SE32 1
        SE08	SE33 1", header = TRUE ) %>%
as_tibble() %>%
mutate (COUNTRY = "SVE",
      change = "recoded",
      from_NUTS3 = '',
      from_ex_NUTS3 = '', convert = TRUE) %>%
Xinxin Yang's avatar
Xinxin Yang committed
mutate_if(is.factor, as.character)
# svn ???####
# before 2006 version: SI00 split into SI01 and SI02 ????????????????
svn <- read.table(
text =  "NUTS2 NUTS2_new regional_surface change convert
        SI00  SI01 '' split TRUE
        SI00  SI02 '' split TRUE
        SI01	SI03 1.03 'boundary shift, recoded' TRUE
        SI02	SI04 0.97 'boundary shift, recoded' TRUE", header = TRUE ) %>%
Xinxin Yang's avatar
Xinxin Yang committed
as_tibble() %>%
mutate (COUNTRY = "SVN", from_NUTS3 = '', from_ex_NUTS3 = '') %>%
mutate_if(is.factor, as.character)
# uki ####
Loading full blame...