Skip to content
Snippets Groups Projects
Commit 05212a68 authored by Simon, Wolfram's avatar Simon, Wolfram
Browse files

Update function_collection.R

external function script
parent 3d8c7be4
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,38 @@ easypackages::packages(c("tidyverse", 'sf', 'raster','sp','dplyr','spatialEco',
"plyr"))
# Loading data ------------------------------------------------------------
# Functions loading dbf SPAM files
FUNload_list_dbf_SPAM <- function(path, type) {
pattern <- switch (type,
"harv" = "_H_",
"phys" = "_A_",
"prod" = "_P_")
path <- list.files(path = path,
full.names = TRUE,
pattern = pattern)
l_dbf <- lapply(path, foreign::read.dbf)
names(l_dbf) <- basename(path)
return(l_dbf)
}
# Functions loading dbf veggie and nuts Monfreda files
FUNload_list_monfreda <- function(path, type) {
pattern <- switch (type,
"harv" = "_HarvestedAreaHectares",
"phys" = "_HarvestedAreaHectares",
"prod" = "_Production")
path <- list.files(path = path,
full.names = TRUE,
pattern = pattern)
l_csv <- lapply(path, read.csv)
names(l_csv) <- basename(path)
return(l_csv)
}
# Crop variable conversion ------------------------------------------------
# Calculate production from yields and area - here: suitable yields
FunProdCalcSuit = function(Area,Yield){
......@@ -29,3 +61,5 @@ Fun_aggregate = function(suitability_dat){
dplyr::summarise(SAR_ha = sum(SAR_ha),
SPR_ton = sum(SPR_ton))
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment