# NOT RUN {
require(uavRst)
##- project folder
projRootDir<-tempdir()
# create subfolders please mind that the pathes are exported as global variables
paths<-link2GI::initProj(projRootDir = projRootDir,
projFolders = c("data/","data/ref/","output/","run/","las/"),
global = TRUE,
path_prefix = "path_")
setwd(path_run)
unlink(paste0(path_run,"*"), force = TRUE)
##- get the rgb image, chm and training data
utils::download.file("https://github.com/gisma/gismaData/raw/master/uavRst/data/ffs.zip",
paste0(path_run,"ffs.zip"))
unzip(zipfile = paste0(path_run,"ffs.zip"),exdir = ".")
##- get geometrical training data assuming that you have used before the calc_ext function
trainDF<-readRDS(paste0(path_run,"tutorial_trainDF.rds"))
load(paste0(path_run,"tutorialbandNames.RData"))
##- define the classes
idNumber=c(1,2,3)
idNames= c("green tree","yellow tree","no tree")
##- add classes names
for (i in 1:length(idNumber)){
trainDF$ID[trainDF$ID==i]<-idNames[i]
}
##- convert to factor (required by rf)
trainDF$ID <- as.factor(trainDF$ID)
##- now prepare the predictor and response variable names
##- get actual name list from the DF
name<-names(trainDF)
##- cut leading and tailing ID/FN
predictNames<-name[3:length(name)-1]
##- call Training
model <- ffs_train(trainingDF= trainDF,
predictors= predictNames,
response = "ID",
spaceVar = "FN",
names = name,
pVal = 0.1,
noClu = 1)
##- for classification/prediction go ahead with the predict_RGB function
##+
# }
Run the code above in your browser using DataLab