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")))
# 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",
                                TRUE ~ "recoded"),
from_NUTS3 = '', from_ex_NUTS3 = '')
# 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 = '')
# 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 = ''
        )
# 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 = '', from_ex_NUTS3 = '')

# 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.77
# IE01. IE06 0.23
# IE02. IE05 0.81
# IE02. IE06 0.42

ire <- read.table(
  text =  "NUTS2 NUTS2_new regional_surface change
  IE01 IE04 0.77 'discontinued, new region'
  IE01 IE06 0.23 'discontinued, new region'
  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 = '') %>%
  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, new region")),
          from_NUTS3 = '',
          from_ex_NUTS3 = '') %>%
  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 = '') %>%
  mutate_if(is.factor, as.character)
# pol ####
pol <- read.table(
text =  "NUTS2 NUTS2_new regional_surface from_NUTS3
      PL11	PL71 1 ''
      PL33	PL72 1 ''
      PL31	PL81 1 ''
      PL32	PL82 1 ''
      PL34	PL84 1 ''
      PL12  PL91 0.17 'PL127+PL129+PL12A-newPL926'
      PL12  PL92 0.83 'PL128+PL12B+PL12C+PL12D+PL12E+newPL926'", header = TRUE ) %>%
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
FI13	FI1D 1
FI1A	FI1D 1
FI18  FI1D 0.01
FI18  FI1B 0.21
FI18  FI1C 0.78
", 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 = '') %>%
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
        SI00  SI01 '' split
        SI00  SI01 '' split
        SI01	SI03 1.03 'boundary shift, new region'
        SI02	SI04 0.97 'boundary shift, new region'", header = TRUE ) %>%
as_tibble() %>%
mutate (COUNTRY = "SVN", from_NUTS3 = '', from_ex_NUTS3 = '') %>%
mutate_if(is.factor, as.character)
# uki ####
uki <- read.table(
text =  "NUTS2 NUTS2_new regional_surface  change from_ex_NUTS3
        # boundary shift