Commit 3080113f authored by Wacker, Jan-David's avatar Wacker, Jan-David
Browse files

Added function for creating mapping table between ISO3 and CiFoS country names

parent 8fa4d433
......@@ -37,13 +37,43 @@ FUNload_list_monfreda <- function(path, type) {
# Loading Model data from local repository
Fun_ModelData = function(sheet){
# loads CiFoS model input data
# INPUT:
# - sheet: string with name of sheet to be read
# OUTPUT:
# - dataframe with sheet content
library("readxl")
if (Sys.getenv("USERNAME") == "wacke003") {
dir = "C:/Users/wacke003/Git/cifos-model.eu/"
} else {
dir = "D:/GAMS/EU_model_Feb2022/"
}
return(read_excel(paste0(dir,"European_CiFoS_model_data.xlsx"),
sheet = sheet))
}
# Loading table with country name mapping
Fun_CountryMapping = function(){
# loads a table with the mapping of ISO3 country names and respective country
# names used in the CiFoS model.
# OUTPUT:
# - tibble with country name mapping
library("readxl")
EU_iso3 = c("AUT","BEL", "BGR", "HRV", "CZE", "DNK", "EST","FIN", "FRA", "DEU",
"GRC", "HUN", "IRL", "ITA","LVA", "LTU", "LUX", "MLT", "NLD", "POL",
"PRT","ROU", "SVK","SVN", "ESP", "SWE", "GBR", "CYP")
if (Sys.getenv("USERNAME") == "wacke003") {
dir_mapping = "C:/Users/wacke003/Git/wolfram/Input_data/Mappings/"
} else {
dir_mapping = "D:/GAMS/EU_model_Feb2022/"
dir_mapping = "C:/Users/simon083/OneDrive - Wageningen University & Research/PhD_WJS/Academic/RQ1/Data_analysis/Spatial_mod/Modified_scripts/R/CifoS_Crop/Input_data/Mappings/"
}
read_excel(paste0(dir_mapping,"European_CiFoS_model_data.xlsx"), sheet = sheet) }
dat_map_SPAM_GAUL_CIFOS_FAO = read.csv(paste(dir_mapping,
"dat_map_SPAM_GAUL_CIFOS_FAO.csv",
sep="")) %>%
as_tibble() %>% dplyr::select(iso3_SPAM, name_cntr_CIFOS2021) %>%
filter(iso3_SPAM %in% EU_iso3)
return(dat_map_SPAM_GAUL_CIFOS_FAO)
}
# Crop variable conversion ------------------------------------------------
# Calculate production from yields and area - here: suitable yields
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment