# 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(file.path(tempdir(),"*"), force = TRUE)
##- get the rgb image, chm and training data
utils::download.file("https://github.com/gisma/gismaData/raw/master/uavRst/data/ffs.zip",
file.path(tempdir(),"ffs.zip"))
unzip(zipfile = file.path(tempdir(),"ffs.zip"),exdir = ".")
##- get geometrical training data assuming that you have used before the calc_ext function
trainDF<-readRDS(file.path(tempdir(),"tutorial_trainDF.rds"))
load(file.path(tempdir(),"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