icraf-indonesia / LUMENSR

An R package for land use planning and management of multiple environmental services.
https://icraf-indonesia.github.io/LUMENSR/
Other
0 stars 0 forks source link

Create an rsx for Pre-QUES #16

Closed dindiarto closed 10 months ago

dindiarto commented 1 year ago

image

dindiarto commented 1 year 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

dindiarto commented 1 year ago

This is a working example with LUMENSR: https://gist.github.com/dindiarto/927f95e08aa24cc8f64679de8a17b6d3#file-lumensr_qgis_r_provider_test-rsx

Follow-up steps:

dindiarto commented 1 year ago

Potential error no 1: Mistakes in input data, please ensure that the input data is correct.

image

dindiarto commented 1 year ago

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.
dindiarto commented 1 year ago

The structure of the rsx for Pre-QUES

image

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]