Skip to contents

Trains a supervised learning or analytical model to define a spatial transformation.

Usage

train_pai_model(gcp_data, method, seed = 123, ...)

Arguments

gcp_data

An sf object of homologous points from read_gcps().

method

A character string specifying the algorithm. One of: "lm","tps", "gam", "rf", or "helmert".

seed

An integer for setting the random seed for reproducibility.

...

Additional arguments passed to the underlying model fitting functions (mgcv::gam, stats::lm, ranger::ranger, fields::Tps).

Value

A trained model object of class pai_model.

Details

This function serves as a factory for creating transformation models. It supports machine learning methods ("lm", "gam", "rf") that learn the relationship between source coordinates and displacement vectors, as well as the analytical "helmert" method which solves for a global similarity transformation.

Important: The more flexible machine learning models, gam and rf, require a sufficient number of data points to produce stable and reliable results. This function will prevent training these models with fewer than 60 homologous points to avoid overfitting. If you have a small number of points, please use the more robust "lm" or "helmert" methods.