View source: R/predict_spatial.R
predict_spatial | R Documentation |
This function allows to directly predict mlr3 learners on various spatial objects.
predict_spatial(
newdata,
learner,
chunksize = 200L,
format = "terra",
filename = NULL
)
newdata |
(terra::SpatRaster | |
learner |
(mlr3::Learner). Learner with trained model. |
chunksize |
( The default of |
format |
( |
filename |
( |
Spatial object of class given in argument format
.
library(terra, exclude = "resample")
# fit rpart on training points
task_train = tsk("leipzig")
learner = lrn("classif.rpart")
learner$train(task_train)
# load raster
stack = rast(system.file("extdata", "leipzig_raster.tif", package = "mlr3spatial"))
# predict land cover classes
pred = predict_spatial(stack, learner, chunksize = 1L)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.