
Generate time steps and file names for an animation of movements
Source:R/fun_animate_data.R
atl_time_steps.Rd
This function creates a sequence of time steps based on a given datetime vector and time interval. It also generates corresponding file names in a provided folder path for each time step.
Arguments
- datetime_vector
A vector of datetime values (POSIXct or similar). Can be a min and max or simple a full vector from the data
- time_interval
A character string specifying the time interval (e.g., "30 sec", "10 min", "1 hour").
- output_path
A character string specifying the directory of the folder where the files will be saved.
- create_path
A logical value. If TRUE, the function creates the directory if it does not exist.
Value
A data.table with two columns:
datetime
: The generated time steps.path
: Corresponding file paths for each time step.
Examples
library(tools4watlas)
# load example data
data <- data_example
# create time steps
ts <- atl_time_steps(
datetime_vector = data$datetime,
time_interval = "10 min",
output_path = tempdir(),
create_path = FALSE
)
ts
#> datetime
#> <POSc>
#> 1: 2023-09-23 01:00:00
#> 2: 2023-09-23 01:10:00
#> 3: 2023-09-23 01:20:00
#> 4: 2023-09-23 01:30:00
#> 5: 2023-09-23 01:40:00
#> ---
#> 135: 2023-09-23 23:20:00
#> 136: 2023-09-23 23:30:00
#> 137: 2023-09-23 23:40:00
#> 138: 2023-09-23 23:50:00
#> 139: 2023-09-24 00:00:00
#> path
#> <char>
#> 1: C:\\Users\\JKRIET~1\\AppData\\Local\\Temp\\RtmpoDGSw1/001.png
#> 2: C:\\Users\\JKRIET~1\\AppData\\Local\\Temp\\RtmpoDGSw1/002.png
#> 3: C:\\Users\\JKRIET~1\\AppData\\Local\\Temp\\RtmpoDGSw1/003.png
#> 4: C:\\Users\\JKRIET~1\\AppData\\Local\\Temp\\RtmpoDGSw1/004.png
#> 5: C:\\Users\\JKRIET~1\\AppData\\Local\\Temp\\RtmpoDGSw1/005.png
#> ---
#> 135: C:\\Users\\JKRIET~1\\AppData\\Local\\Temp\\RtmpoDGSw1/135.png
#> 136: C:\\Users\\JKRIET~1\\AppData\\Local\\Temp\\RtmpoDGSw1/136.png
#> 137: C:\\Users\\JKRIET~1\\AppData\\Local\\Temp\\RtmpoDGSw1/137.png
#> 138: C:\\Users\\JKRIET~1\\AppData\\Local\\Temp\\RtmpoDGSw1/138.png
#> 139: C:\\Users\\JKRIET~1\\AppData\\Local\\Temp\\RtmpoDGSw1/139.png