Skip to content

Commit

Permalink
Initiate transformation_to_layer1+.R
Browse files Browse the repository at this point in the history
  • Loading branch information
heleenderoo committed Mar 22, 2024
1 parent 34d1c7b commit 53fbe64
Showing 1 changed file with 111 additions and 0 deletions.
111 changes: 111 additions & 0 deletions src/transformation_to_layer1/transformation_to_layer1+.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,127 @@ read_processed(path_name = "./data/layer1_data/",



# Input level ----

level <- "LI"
level <- "LII"



# 3. Gap-fill bulk densities for mineral layers ----

source("./src/functions/gapfill_with_predictions.R")

if (level == "LI") {

s1_som <- gapfill_with_predictions(survey_form = "s1_som",
data_frame = s1_som,
save_to_env = FALSE)

s1_pfh <- gapfill_with_predictions(survey_form = "s1_pfh",
data_frame = s1_pfh,
save_to_env = FALSE)
}


if (level == "LII") {

so_som <- gapfill_with_predictions(survey_form = "so_som",
data_frame = so_som,
save_to_env = FALSE)

so_pfh <- gapfill_with_predictions(survey_form = "so_pfh",
data_frame = so_pfh,
save_to_env = FALSE)
}




# 4. Tidy up dataframes ----

source("./src/functions/tidy.R")

if (level == "LI") {

s1_som <- tidy(survey_form = "s1_som",
data_frame = s1_som,
save_to_env = FALSE)

s1_pfh <- tidy(survey_form = "s1_pfh",
data_frame = s1_pfh,
save_to_env = FALSE)
}


if (level == "LII") {

so_som <- tidy(survey_form = "so_som",
data_frame = so_som,
save_to_env = FALSE)

so_pfh <- tidy(survey_form = "so_pfh",
data_frame = so_pfh,
save_to_env = FALSE)
}




# 5. Get stratifiers ----

source("./src/functions/get_stratifiers.R")

if (level == "LI") {

s1_strat <- get_stratifiers(level = "LI")

write.table(s1_strat,
file = paste0("./data/additional_data/s1_strat.csv"),
row.names = FALSE,
na = "",
sep = ";",
dec = ".")
}

if (level == "LII") {

so_strat <- get_stratifiers(level = "LII")

write.table(so_strat,
file = paste0("./data/additional_data/so_strat.csv"),
row.names = FALSE,
na = "",
sep = ";",
dec = ".")
}





# 5. Export the processed survey forms ----

## 5.1. Save processed survey forms to Google Drive (layer 1) ----

source("./src/functions/save_to_google_drive.R")
save_to_google_drive(objects_to_save = c("si", "so", "sw"),
path_name = "layer1_data")

source("./src/functions/save_to_google_drive.R")
save_to_google_drive(objects_to_save = c("y1", "s1"),
path_name = "layer1_data")

source("./src/functions/save_to_google_drive.R")
save_to_google_drive(path_name = "layer1_data")



## 5.2. Sync local data with Google Drive ----

source("./src/functions/sync_local_data.R")
sync_local_data(list_subfolders_data = "layer1_data",
list_subfolders_output = FALSE)



Expand Down

0 comments on commit 53fbe64

Please sign in to comment.