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
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
evoland_db$new()
Initialize a new evoland_db object
Usage
evoland_db$new(path, id_run = 0L, read_only = FALSE, ...)evoland_db$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.
evoland_db$set_report()
Set reporting metadata, see db_set_report()
evoland_db$set_neighbors()
Set the neighbors table, see set_neighbors()
evoland_db$generate_neighbor_predictors()
Generate neighbor prediction table, i.e. "how many neighbors within
distance X are of type Y", see generate_neighbor_predictors()
evoland_db$upsert_new_neighbors()
Append new neighbors to predictor for a given period; depends on generate_neighbor_predictors() having been run.
evoland_db$add_predictor()
Add a predictor using the currently active id_run, see add_predictor()
Usage
evoland_db$add_predictor(
pred_data_raw,
name,
fill_value,
pretty_name = name,
description = NA_character_,
orig_format = NA_character_,
sources = data.frame(url = character(0), md5sum = character(0)),
unit = NA_character_
)Arguments
pred_data_rawData frame with columns
id_coord,id_period, andvaluenameUnique short name
fill_valueValue to substitute if a coordinate point in coords_t does not have an explicit associated value
pretty_namechar, Friendly name for use in reporting
descriptionchar, For use in reporting.
orig_formatchar, Format description of the underlying data (raster, vector…)
sourcesdata.frame with url/md5sum columns, used for keeping track of underlying raw data, see
download_and_verify()unitchar, SI unit for physical predictors, or descriptions like "bed nights/year" as a proxy for touristic activity
evoland_db$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
evoland_db$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
evoland_db$alloc_dinamica()
Runs a path-dependent Monte Carlo simulation using Dinamica
EGO, see alloc_dinamica()
Usage
evoland_db$alloc_dinamica(
id_periods,
select_score,
select_maximize,
work_dir = "dinamica_rundir",
keep_intermediate = FALSE
)Arguments
id_periodsInteger vector of period IDs to include in the simulation.
select_scoreCharacter string; mlr3 measure ID (e.g.
"classif.auc") used to select model for extrapolationselect_maximizeLogical; maximize (
TRUE) or minimize (FALSE) the score.work_dirCharacter path for Dinamica working directory. Default "dinamica_rundir".
keep_intermediateLogical, keep intermediate Dinamica files? Default FALSE.
evoland_db$eval_alloc_params_t()
Evaluates allocation parameters in dinamica, see eval_alloc_params_t()
Usage
evoland_db$eval_alloc_params_t(
select_score,
select_maximize,
work_dir = "dinamica_rundir",
keep_intermediate = FALSE
)Arguments
select_scoreCharacter string; mlr3 measure ID (e.g.
"classif.auc") used to select model for extrapolationselect_maximizeLogical; maximize (
TRUE) or minimize (FALSE) the score.work_dirCharacter path for Dinamica working directory. Default "dinamica_rundir".
keep_intermediateLogical, keep intermediate Dinamica files? Default FALSE.
evoland_db$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
evoland_db$lulc_data_as_rast()
Retrieve LULC data as a SpatRaster object for a given
period. See lulc_data_as_rast()
evoland_db$fit_full_models()
Fit full models (trained on the complete dataset) for each viable transition,
see fit_full_models(). Two mutually exclusive modes: pass learner to train
directly, or pass select_score to pick the best partial model by score.
Usage
evoland_db$fit_full_models(
learner = NULL,
select_score = NULL,
select_maximize = TRUE,
cluster = NULL
)Arguments
learnerAn mlr3
LearnerorAutoTunerfor direct-learner mode (NULLwhenselect_scoreis used).select_scoreMeasure ID string for score-select mode, e.g.
"classif.auc"(NULLwhenlearneris used).select_maximizeLogical; maximize (
TRUE) or minimize (FALSE) the score.clusterOptional cluster object for parallel processing
evoland_db$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(
learner,
measures,
sample_frac = 0.7,
seed = NULL,
cluster = NULL
)Arguments
learnerAn mlr3
LearnerorAutoTunerR6 object.measuresA vector of
Measurenames passed to mlr3::msr or a list ofMeasureobjects for scoring the held-out split.sample_fracFraction in \(0, 1\) for stratified sampling.
seedRandom seed for reproducible sampling
clusterOptional cluster object for parallel processing
evoland_db$get_crossval_plots()
Get cross-validation plots for stored predictions, see get_crossval_plots()
evoland_db$set_full_trans_preds()
Set an initial full set of transition / predictor relations, see set_full_trans_preds()
evoland_db$get_pred_filter_score()
Add filter scores to predictors for each id_run, id_trans.
See get_pred_filter_score().
Arguments
filterCharacter passed to mlr3filters::flt or mlr3filters::Filter object specifying the filter method to use for feature selection.
clusterOptional cluster object for parallel processing
...Additional arguments passed to
flt.
evoland_db$predict_trans_pot()
Predict the transition potential for a given period, see trans_pot_t()
evoland_db$get_obs_trans_rates()
Get the transition rates that were observed, see trans_rates_t