if (sits_run_examples()) {
# create a data cube from local files
data_dir <- system.file("extdata/raster/mod13q1", package = "sits")
cube <- sits_cube(
source = "BDC",
collection = "MOD13Q1-6",
data_dir = data_dir,
delim = "_",
parse_info = c("X1", "tile", "band", "date")
)
# create a random forest model
rfor_model <- sits_train(samples_modis_ndvi, sits_rfor())
# classify a data cube using rfor model
probs_rfor_cube <- sits_classify(data = cube, ml_model = rfor_model)
# create an XGBoost model
xgb_model <- sits_train(samples_modis_ndvi, sits_xgboost())
# classify a data cube using xgboost model
probs_xgb_cube <- sits_classify(data = cube, ml_model = xgb_model)
# create a list of predictions to be combined
pred_cubes <- list(probs_rfor_cube, probs_xgb_cube)
# combine predictions
comb_probs_cube <- sits_combine_predictions(cubes = pred_cubes)
# plot the resulting combined prediction cube
plot(comb_probs_cube)
}
Run the code above in your browser using DataLab