split_df: split_df

View source: R/split_df.R

split_dfR Documentation

split_df

Description

This is a function to divide the SCOPE inputs per period, parts or pixels to run the simulations.

Usage

split_df(
  df,
  split_by,
  n_parts,
  name_file = "Inputs_",
  folder_files,
  pixel = FALSE,
  pixel_id
)

Arguments

df

a data.frame with a datetime variable required to SCOPE (BerkeleyJulianDate) and pixel numbers

split_by

for period use "season" for quarters, "month", "week", "doy" for day of the year. For equal parts use "parts" and for a one or more pixels use "id_pixel".

n_parts

if "parts", an number to divide into

name_file

for the file name start with

folder_files

directory to be save

pixel

logical, if TRUE split by pixel, default is FALSE

pixel_id

if pixel is TRUE, the id number of the pixel(s)

Value

It will save the split files in the SCOPE directory.

Examples

split and save in different files to facilitate the processing
## divided by parts
df_splited <- split_df(df = Inputs_Berlin_masked,
                      split_by = "parts", #season #month, #week, #doy , #parts
                      n_parts = 2, ### if parts , how many?
                      name_file = "Inputs_",
                      folder_files = "D:/SCOPE-master/input/dataset for_verification/")

## divided by period
df_splited <- split_df(df = Inputs_Berlin_masked,
                      split_by = "season",
                      name_file = "Inputs_",
                      folder_files = "D:/SCOPE-master/input/dataset for_verification/")

## divided by pixel
raster::extract(krg_mask, tower_points_utm, buffer = 1000) # near the EC_tower

df_splited <- split_df(df = Inputs_Berlin_masked,
                      split_by = "id_pixel",
                      pixel_id = c(1169, 882), # ROTH and TUCC
                      name_file = "Inputs_",
                      folder_files = "D:/SCOPE-master/input/dataset for_verification/")

df_splited


AlbyDR/rSCOPE documentation built on Dec. 19, 2024, 7:29 p.m.