Skip to content
Snippets Groups Projects
Commit 8c45028c authored by clblatte's avatar clblatte
Browse files

comment out creating individual csv files for wathersheds

parent cf5a68f2
No related branches found
No related tags found
No related merge requests found
......@@ -16,44 +16,44 @@ library(dplyr)
# Variant 1: create a single dataframe for each SQL Database (selected columns of table UNIT)
# Dataframes are given the names of the DB and column "test" is added with the name of the DB
for (name in db_names){
# name = "MV_Hartola"
db <- dbConnect(dbDriver("SQLite"), dbname = paste0(path,"input_data/simulated_", sim_variant, "_", name, "_rsu.db"))
rsl <- dbGetQuery( db, paste0("select ", columns, " from UNIT"))
rsl$gpkg <- name
dbDisconnect(db)
### Add the abbreviation of the regimes
rsl <- rsl %>%
left_join(regime, by = "branching_group", all.x = TRUE)
### Filter those stands that caused errors during the simulation with SIMO
# import csv file that contains the error stands
error_stands <- read.csv(paste0(path, "params/errors_watersheds.csv"), sep = ",", header = TRUE, stringsAsFactors = FALSE)
error_stands$id <- as.character(error_stands$id)
rsl <- rsl %>%
anti_join(error_stands, by = c("id", "gpkg"))
### Rename set aside scenario if it considers deadwood extraction
if(sim_variant %in% c("CC45", "CC85", "without", "CC45_p", "CC85_p", "CC26_p", "CC0_p", "CC45_p_canesm", "CC85_p_canesm", "CC26_p_canesm", "CC0_p_canesm")) {
rsl <- rsl %>% mutate(regime = ifelse(regime %in% "SA", "SA_DWextract", regime))
}
write.table(rsl, paste0(path, "output/rsl_",sim_variant,"_",name,".csv" ), sep = ";", row.names = F, col.names = TRUE)
assign( paste("rsl", name, sep="_"), rsl)
rm(db, rsl)
}
# # Variant 1: create a single dataframe for each SQL Database (selected columns of table UNIT)
# # Dataframes are given the names of the DB and column "test" is added with the name of the DB
#
# for (name in db_names){
#
# # name = "MV_Hartola"
# db <- dbConnect(dbDriver("SQLite"), dbname = paste0(path,"input_data/simulated_", sim_variant, "_", name, "_rsu.db"))
# rsl <- dbGetQuery( db, paste0("select ", columns, " from UNIT"))
# rsl$gpkg <- name
# dbDisconnect(db)
#
# ### Add the abbreviation of the regimes
# rsl <- rsl %>%
# left_join(regime, by = "branching_group", all.x = TRUE)
#
# ### Filter those stands that caused errors during the simulation with SIMO
# # import csv file that contains the error stands
# error_stands <- read.csv(paste0(path, "params/errors_watersheds.csv"), sep = ",", header = TRUE, stringsAsFactors = FALSE)
# error_stands$id <- as.character(error_stands$id)
#
# rsl <- rsl %>%
# anti_join(error_stands, by = c("id", "gpkg"))
#
#
# ### Rename set aside scenario if it considers deadwood extraction
# if(sim_variant %in% c("CC45", "CC85", "without", "CC45_p", "CC85_p", "CC26_p", "CC0_p", "CC45_p_canesm", "CC85_p_canesm", "CC26_p_canesm", "CC0_p_canesm")) {
#
# rsl <- rsl %>% mutate(regime = ifelse(regime %in% "SA", "SA_DWextract", regime))
#
# }
#
#
# write.table(rsl, paste0(path, "output/rsl_",sim_variant,"_",name,".csv" ), sep = ";", row.names = F, col.names = TRUE)
#
# assign( paste("rsl", name, sep="_"), rsl)
# rm(db, rsl)
#
# }
# Variant 2: create one hughe dataframe combining all SQL databases (selected columns of table UNIT)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment