predict_rgb: classify images using raster predict

Description Usage Arguments Value Examples

View source: R/rs_classify.R

Description

classify images using raster predict

Usage

1
2
3
4
5
6
7
8
predict_rgb(
  imageFiles = NULL,
  model = NULL,
  inPrefix = "index_",
  outPrefix = "classified_",
  bandNames = NULL,
  retRaster = TRUE
)

Arguments

imageFiles

raster*. imagestack for classification purposes must contain the required bands as needed by the model.

model

model. classification model

inPrefix

character. in frefix string

outPrefix

character. out prefix string

bandNames

character. band names

retRaster

boolean if TRUE a raster stack is returned

Value

writes a result image in tif format if retRaster an rasterstack is returned

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
## Not run: 
##- required packages
require(uavRst)
require(link2GI)

##- project folder
projRootDir<-tempdir()

##-create subfolders pls notice 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_")
unlink(file.path(tempdir(),"*"), force = TRUE)

##- get the tutorial 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 = tempdir())

##- assign tutorial data
imageFile <- file.path(tempdir(),"predict.tif")
load(file.path(tempdir(),"tutorialbandNames.RData"))
tutorialModel<-readRDS(file = file.path(tempdir(),"tutorialmodel.rds"))

##- start the  prediction taking the non optimized model
##- please note the output is saved in the subdirectory path_output
prediction<-predict_rgb(imageFiles=imageFile,
            model = tutorialModel[[1]],
            bandNames = bandNames)

##- visualise the classification
raster::plot(prediction)
##+
## End(Not run)

uavRst documentation built on Dec. 30, 2019, 5:06 p.m.