3. AOA in Parallel
Estimating the Area of Applicability (AOA) can be computationally intensive, depending on the amount of training data used for a model as well as the amount of new data the AOA has to be computed. This vignette goes over the possibility to (partly) compute the AOA in parallel. We will use the same data setup as the vignette “Area of applicability of spatial prediction models”. Please have a look there for a general introduction to the AOA and the details about the example data generation.
data("splotdata") predictors <- rast(system.file("extdata","predictors_chile.tif",package="CAST")) splotdata <- st_drop_geometry(splotdata)
For better performances, it is recommended to compute the AOA in two
steps. First, the DI of training data and the resulting DI threshold is
computed from the model or training data with the function
trainDI. The result from trainDI is usually the first step
aoa function, however it can be skipped by providing
the trainDI object in the function call. This makes it possible to
compute the AOA on multiple raster tiles at once (e.g. on different
cores). This is especially useful for very large prediction areas,
e.g. in global mapping.
## DI of 703 observation ## Predictors: bio_1 bio_4 bio_5 bio_6 bio_8 bio_9 bio_12 bio_13 bio_14 bio_15 elev ## ## AOA Threshold: 0.1941761
If you have a large raster, you divide it into multiple smaller tiles and apply the trainDI object afterwards to each tile.
trainDI argument in the
function to specify, that you want to use a previously computed trainDI
You can now run the aoa function in parallel on the different tiles!
Of course you can use for favorite parallel backend for this task, here
we use mclapply from the
For larger tasks it might be useful to save the tiles to you hard-drive and load them one by one to avoid filling up your RAM.