Learn R Programming

SpatialDownscaling (version 0.1.2)

predict.BCSD: Predict method for BCSD model

Description

This function generates predictions using a trained BCSD model.

Usage

# S3 method for BCSD
predict(object, newdata, ...)

Value

A matrix, array or raster of the downscaled predictions at fine resolution.

Arguments

object

A BCSD model object, an output of the bcsd function.

newdata

Array or raster that has the new coarse resolution data to be downscaled. The resolution should match the resolution of the training data. The first two dimensions are the spatial dimensions and the third refers to the training samples (e.g. time).

...

Additional arguments (not used).

Details

The predict method applies the trained BCSD model to new coarse resolution data. It performs bias correction using the quantile mapping function and then applies spatial interpolation, specified during model training with the method parameter, to generate fine resolution predictions.

See Also

bcsd for training the model.

Examples

Run this code
# Simple example with random data
coarse <- array(rnorm(10*20*30), dim = c(10, 20, 30))  # time x lat x lon
fine <- array(rnorm(10*40*60), dim = c(10, 40, 60))    # time x lat x lon
model <- bcsd(coarse, fine, method = "bilinear", n_quantiles = 100)
# New coarse data for prediction
new_coarse <- array(rnorm(5*20*30), dim = c(5, 20, 30))  # time x lat x lon
predictions <- predict(model, new_coarse)
# Check dimensions of predictions
dim(predictions)  # Should be (5, 40, 60) for time x lat x lon

Run the code above in your browser using DataLab