Closed dindiarto closed 10 months ago
This script serves as a test to ensure the R Processing Provider functions, by verifying its compatibility with key R data structures such as Raster (SpatRaster) and Data Frame types.
https://gist.github.com/dindiarto/927f95e08aa24cc8f64679de8a17b6d3
This is a working example with LUMENSR: https://gist.github.com/dindiarto/927f95e08aa24cc8f64679de8a17b6d3#file-lumensr_qgis_r_provider_test-rsx
Follow-up steps:
ques_pre_output <- ques_pre(lc_t1_, lc_t2_, admin_z, cutoff_landscape = cutoff_landscape, cutoff_pu = cutoff_pu, convert_to_Ha = TRUE)
~- [x] Save ques_pre_output as an RDS file in a user-specified directory.~
saveRDS(ques_pre_output, file = paste0(Sys.getenv("HOME"), "/LUMENS_ques_pre_output.rds"))
readRDS(paste0(Sys.getenv("HOME"), "/LUMENS_ques_pre_output.rds"))
~- [ ] Load the RDS file and check the objects it contains.~ ~- [ ] Store the QMD file in a user's directory.~ ~- [ ] Load the RDS file, render the QMD, and prove it works.~ ~- [ ] Document these steps and display them as a pipeline chart.~
Potential error no 1: Mistakes in input data, please ensure that the input data is correct.
I could not save (1) tidyterra
and (2) magick
image files either into RDS or RDA
(1)
## Error in .External(list(name = "CppMethod__invoke_notvoid", address = <pointer: (nil)>, :
## NULL value passed as symbol address
(2)
> a$input_dataviz$plot_admin
Error: Image pointer is dead. You cannot save or cache image objects between R sessions.
graph TD
A[Load required libraries] --> B[Convert the first column of lookups to numeric]
B --> C[Check if Tahun_periode_1 and Tahun_periode_2 are characters]
C --> D[Create raster objects from lc_t1_, lc_t2_, and admin_]
D --> E[Load the land cover data for period 1990 and add legend]
D --> F[Load the land cover data for period 2020 and add legend]
D --> G[Load the planning unit data]
H[Define area cutoffs for landscape and planning unit]
H --> I
E --> I
F --> I
G --> I[Execute the 'ques_pre' function and get output]
I --> J[Create a temporary directory]
L --> K[Write raster objects to the temporary directory]
J --> L[Set paths for input files and save 'ques_pre_output' to .rds file]
N --> M[Copy necessary files for quarto rendering]
K --> N[Get basenames of raster and .rds files]
M --> P[Check if quarto and required quarto_version are available]
P --> Q[Render the quarto report using input files]
Q --> R[Copy the generated report and files to the home directory]