diff --git a/SPAM_Data_Transformation/SPAM2010_aggregationADM1.R b/SPAM_Data_Transformation/SPAM2010_aggregationADM1.R index 442bcffdcd3770bf6bd3f0872e3d1d3ed6c2941e..b21fdc6e328319fcf6eef1a8dd8eee1fcd8d7626 100644 --- a/SPAM_Data_Transformation/SPAM2010_aggregationADM1.R +++ b/SPAM_Data_Transformation/SPAM2010_aggregationADM1.R @@ -888,6 +888,14 @@ write.csv(dat_spam_global, here::here("Input_data", "Core_data", "SPAM_GGS_all_g # Subsetting EU ----------------------------------------------------------- + +# Preparing the final EU validation data based on Renee's idea ------------ +# Aim is to aggregate harvested area per country + +# Getting full CIFOS country names +dat_country <- read_excel("DataValidationFinal.xlsx", + sheet = "Sheet1") %>% + rename(crop=crop_SPAM) # SUBSETTING FOR EU-27 GGS ---------------------------------------------------------------------- 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") @@ -897,11 +905,30 @@ EU_iso3 = c("AUT","BEL", "BGR", "HRV", "CZE", "DNK", "EST","FIN", "FRA", "DEU", # Check if the EU countries iso3 are all present in dat.phys etc. # EU_iso3 %in% dat.phys$iso3 #Validation if all EU27 countries are in the dfs below dat.SPAM.EU = dat_spam_global %>% #Pixel level data - filter(iso3 %in% EU_iso3) + filter(iso3 %in% EU_iso3) %>% + group_by(iso3, crop) %>% + summarise(sum(H), sum(A)) %>% + left_join(., dat_country, by = "iso3") %>% + dplyr::select(iso3, crop, `sum(H)`, `sum(A)`) %>% + rename(HarvestedArea_ha = `sum(H)`, + PhysicalArea_ha = `sum(A)`) #%>% + left_join(., dat_country, by = "crop") #%>% + dplyr::select(iso3, Country, crop_SPAM, `sum(H)`, `sum(A)`, crop_SPAM_long, FAO_no, crop_FAO) %>% + + + write.csv(dat.SPAM.EU, here::here("Input_data", "Core_data", "SPAM_Crops_EU27_alltecRec_nuts_veg.csv"))#, # locale = locale(encoding = "LATIN2")) + + + + + + + + # TREENUTS WITH GADM ------------------------------------------------------ # # Load and check shapefile # wd=setwd(here("Input_data"))