Package website: release | dev
mlr3spatial is an extension package for spatial objects within the mlr3 ecosystem.
leipzig
.Check out mlr3spatiotempcv for spatiotemporal resampling within mlr3.
Install the last release from CRAN:
install.packages("mlr3spatial")
Install the development version from GitHub:
::install_github("mlr-org/mlr3spatial") remotes
library(mlr3)
library(mlr3spatial)
library(terra, exclude = "resample")
library(sf)
# load sample points
= read_sf(system.file("extdata", "leipzig_points.gpkg", package = "mlr3spatial"), stringsAsFactors = TRUE)
leipzig_vector
# create land cover task
= as_task_classif_st(leipzig_vector, target = "land_cover")
task task
## <TaskClassifST:leipzig_vector> (97 x 9)
## * Target: land_cover
## * Properties: multiclass
## * Features (8):
## - dbl (8): b02, b03, b04, b06, b07, b08, b11, ndvi
## * Coordinates:
## X Y
## 1: 732480.1 5693957
## 2: 732217.4 5692769
## 3: 732737.2 5692469
## 4: 733169.3 5692777
## 5: 732202.2 5692644
## ---
## 93: 733018.7 5692342
## 94: 732551.4 5692887
## 95: 732520.4 5692589
## 96: 732542.2 5692204
## 97: 732437.8 5692300
# load learner
= lrn("classif.rpart")
learner
# train the model
$train(task)
learner
# load raster file
= rast(system.file("extdata", "leipzig_raster.tif", package = "mlr3spatial")) leipzig_raster
plotRGB(leipzig_raster, r = 3, g = 2, b = 1)
# create predict task
= as_task_unsupervised(leipzig_raster)
task_predict
# predict land cover map
= predict_spatial(task_predict, learner) land_cover
plot(land_cover)
Eventually. It is not yet clear whether these would live in
mlr3extralearners or in {mlr3spatial}. So far there are none yet.
mlr3spatiotempcv is solely devoted to resampling techniques.
There are quite a few and keeping packages small is one of the
development philosophies of the mlr3 framework. Also back in the days
when mlr3spatiotempcv was developed it was not yet clear how we want to
structure additional spatial components such as prediction support for
spatial classes and so on.