makeSpatialization: make a spatialization of a gridded dataset using a mlr model

Description Usage Arguments Value Author(s) Examples

View source: R/makeSpatialization.R

Description

make a spatialization of a gridded dataset using a mlr model

Usage

1
makeSpatialization(model, pred.grid = grid.df)

Arguments

model

an object of class mlr::train() that contains the prediction model

pred.grid

an object of class sf::st_makegrid(). This object must contains the same column names as the task on which the model has been trained

Value

A 2 elements named list

Author(s)

Thomas Goossens

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## Not run: 
# load magrittr for pipe use : %>%
library(magrittr)
# create the dataset
myDataset = makeDataset(
  dfrom = "2017-03-04T15:00:00Z",
  dto = "2017-03-04T18:00:00Z",
  sensor = "tsa")

# extract the list of hourly sets of records
myDataset = myDataset$output$value

# create the tasks
myTasks = purrr::map(myDataset, makeTask, target = "tsa")

# extract the tasks from the outputs
myTasks = myTasks %>% purrr::modify_depth(1, ~.$"output"$"value"$"task")

# keep the first task
myTask = myTasks[[1]]

# create the model
myModel = makeModel(
  task = myTask,
  learner = agrometeorLearners$mulLR_lonLatAlt_NA)

# extract the relevant information
myModel = myModel$output$value

# spatialize using the trained model
mySpatialization = makeSpatialization(
model = myModel$trained,
pred.grid = grid.df) # grid.df comes precompiled with the package

# get the relevant information
mySpatialization = mySpatialization$output$value

# show an excerpt of the spatialized data
head(mySpatialization$spatialized)

# show the summary stats of spatialized data
head(mySpatialization$summary)

## End(Not run)

pokyah/agrometeoR documentation built on May 26, 2019, 7 p.m.