An R6 class that provides an interface to a folder-based data storage system for the evoland package. Each table is stored as a parquet (or JSON) file. This class uses DuckDB for in-memory SQL operations while persisting data to disk in parquet format for better compression.
Inherits from parquet_db for generic database operations.
See also
Additional methods and active bindings are added to this class in separate files:
evoland_db_views - View active bindings (lulc_meta_long_v, etc.) and methods
Super class
evoland::parquet_db -> evoland_db
Active bindings
coords_tGet or upsert coords_t
periods_tGet or upsert periods_t
lulc_meta_tGet or upsert lulc_meta_t
lulc_data_tGet or upsert lulc_data_t
pred_data_tGet or upsert pred_data_t
pred_meta_tGet or upsert pred_meta_t
trans_meta_tGet or upsert trans_meta_t
trans_preds_tGet or upsert trans_preds_t
trans_rates_tGet or upsert trans_rates_t
intrv_meta_tGet or upsert intrv_meta_t
intrv_masks_tGet or upsert intrv_masks_t
trans_models_tGet or upsert trans_models_t
alloc_params_tGet or upsert alloc_params_t
neighbors_tGet or upsert neighbors_t
reporting_tGet or upsert reporting_t
runs_tGet or upsert runs_t
id_runGet or set active id_run, see runs_t
run_lineageGet id_run, see runs_t
Methods
Inherited methods
evoland::parquet_db$column_max()evoland::parquet_db$commit()evoland::parquet_db$delete_from()evoland::parquet_db$execute()evoland::parquet_db$fetch()evoland::parquet_db$get_query()evoland::parquet_db$get_table_metadata()evoland::parquet_db$get_table_path()evoland::parquet_db$list_tables()evoland::parquet_db$row_count()
Method trans_rates_dinamica_v()
Method new()
Initialize a new evoland_db object
Usage
evoland_db$new(path, id_run = 0L, read_only = FALSE, ...)Method get_read_expr()
Get SQL expression to read a table, respecting active run hierarchy. For each data slice, returns data from the closest ancestor run that has it.
Method print()
Print method for evoland_db
Method set_report()
Set reporting metadata, see db_set_report()
Method set_neighbors()
Set the neighbors table, see set_neighbors()
Method generate_neighbor_predictors()
Generate neighbor prediction table, i.e. "how many neighbors within
distance X are of type Y", see generate_neighbor_predictors()
Method upsert_new_neighbors()
Append new neighbors to predictor for a given period; depends on generate_neighbor_predictors() having been run.
Method trans_pred_data_v()
Get transitions along with their predictor data in a wide
data.table, see trans_pred_data_v()
Arguments
id_transInteger transition ID, see trans_meta_t
id_predOptional integer vector of predictor IDs to include
orderedif TRUE, order output by
id_coord&id_period
Method pred_data_wide_v()
Retrieve a wide view of the predictor data, see pred_data_wide_v()
Arguments
id_transInteger transition ID, see trans_meta_t
id_period_anteriorInteger ID of period to retrieve data for
Method alloc_dinamica()
Runs a path-dependent Monte Carlo simulation using Dinamica
EGO, see alloc_dinamica()
Usage
evoland_db$alloc_dinamica(
id_periods,
gof_criterion,
gof_maximize,
work_dir = "dinamica_rundir",
keep_intermediate = FALSE
)Arguments
id_periodsInteger vector of period IDs to include in the simulation.
gof_criterionWhich goodness-of-fit metric to use for model selection (e.g., "auc")
gof_maximizeMaximize (TRUE) or minimize (FALSE) the gof_criterion?
work_dirCharacter path for Dinamica working directory. Default "dinamica_rundir".
keep_intermediateLogical, keep intermediate Dinamica files? Default FALSE.
Method eval_alloc_params_t()
Evaluates allocation parameters in dinamica, see eval_alloc_params_t()
Usage
evoland_db$eval_alloc_params_t(
gof_criterion,
gof_maximize,
work_dir = "dinamica_rundir",
keep_intermediate = FALSE
)Arguments
gof_criterionWhich goodness-of-fit metric to use for model selection (e.g., "auc")
gof_maximizeMaximize (TRUE) or minimize (FALSE) the gof_criterion?
work_dirCharacter path for Dinamica working directory. Default "dinamica_rundir".
keep_intermediateLogical, keep intermediate Dinamica files? Default FALSE.
Method create_alloc_params_t()
Computes allocation parameters for all viable transitions, see create_alloc_params_t()
Arguments
n_perturbationsNumber of perturbed parameter sets to generate, each assigned to a in id_run in runs_t
sdStandard deviation for random perturbation of frac_expander
Method lulc_data_as_rast()
Retrieve LULC data as a SpatRaster object for a given
period. See lulc_data_as_rast()
Method fit_full_models()
Fit full models on complete data using the best partial model configuration for
each transition, see fit_full_models()
Arguments
partial_modelsA trans_models_t table with partial models (see
fit_partial_models())gof_criterionWhich goodness-of-fit metric to use for model selection (e.g., "auc")
gof_maximizeMaximize (TRUE) or minimize (FALSE) the gof_criterion?
clusterOptional cluster object for parallel processing
Method fit_partial_models()
Fit partial models for each viable transition using stratified
sampling. Models are trained on a subsample and evaluated on held-out data, see
fit_partial_models() for details.
Usage
evoland_db$fit_partial_models(
fit_fun,
sample_frac = 0.7,
gof_fun,
seed = NULL,
cluster = NULL,
...
)Arguments
fit_funFunction for generating a model object.
sample_fracFraction in \(0, 1\) for stratified sampling.
gof_funFunction to evaluate goodness of fit.
seedRandom seed for reproducible sampling
clusterOptional cluster object for parallel processing
...additional arguments passed to fit_fun
Method set_full_trans_preds()
Set an initial full set of transition / predictor relations, see set_full_trans_preds()
Method get_pruned_trans_preds_t()
Remove predictors from the transition-predictor relation, aka
feature selection. See get_pruned_trans_preds_t().
Arguments
filter_funDefaults to
covariance_filter(), seeget_pruned_trans_preds_t()for details.clusterOptional cluster object for parallel processing
...Additional arguments passed to
filter_fun.
Method predict_trans_pot()
Predict the transition potential for a given period, see trans_pot_t()
Method get_obs_trans_rates()
Get the transition rates that were observed, see trans_rates_t