calc_ext: Convenient function to preprocess synthetic raster bands from...

Description Usage Arguments Details Value Note Examples

Description

Convenient function to preprocess synthetic raster bands from a given RGB image and/or DTM/DSM data. Currently for all chanels of the input images the following textures and indices can be calculated:
rgb indices (17), color transformation (9), haralick (3 = 25 layers), statitics (4),edge (3),morpho (4), DEM Parameter (20). All layers will be stacked (as an ENVI file). If wanted the raster values can be extracted to a data frames by overlaying corresponding vector data. NOTE: The vector data has to be named identically to the rasterfiles. This is useful for for classification training purposes and covers usually step 1 of the random forest based classification of UAV derived visible imagery and point clouds.

Usage

 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
calc_ext(
  calculateBands = FALSE,
  extractTrain = TRUE,
  prefixRun = "temp",
  patterndemFiles = "dem",
  prefixTrainImg = "",
  prefixTrainGeom = "",
  suffixTrainImg = "",
  suffixTrainGeom = "",
  patternIdx = "index",
  patternImgFiles = "",
  channels = c("red", "green", "blue"),
  hara = TRUE,
  haraType = c("simple", "advanced", "higher"),
  stat = TRUE,
  edge = TRUE,
  edgeType = c("gradient", "sobel", "touzi"),
  morpho = TRUE,
  morphoType = c("dilate", "erode", "opening", "closing"),
  rgbi = TRUE,
  indices = c("VVI", "VARI", "NDTI", "RI", "SCI", "BI", "SI", "HI", "TGI", "GLI",
    "NGRDI", "GRVI", "GLAI", "HUE", "CI", "SAT", "SHP"),
  rgbTrans = TRUE,
  colorSpaces = c("CIELab", "CMY", "Gray", "HCL", "HSB", "HSI", "Log", "XYZ", "YUV"),
  pardem = TRUE,
  demType = c("hillshade", "slope", "aspect", "TRI", "TPI", "Roughness", "SLOPE",
    "ASPECT", "C_GENE", "C_PROF", "C_PLAN", "C_TANG", "C_LONG", "C_CROS", "C_MINI",
    "C_MAXI", "C_TOTA", "C_ROTO", "MTPI"),
  morphoMethod = 6,
  minScale = 1,
  maxScale = 8,
  numScale = 2,
  kernel = 3,
  currentDataFolder = NULL,
  currentIdxFolder = NULL,
  cleanRunDir = TRUE,
  sagaLinks = NULL,
  gdalLinks = NULL,
  otbLinks = NULL
)

Arguments

calculateBands

logical. switch for set on calculation of syntheic bands and indices default = TRUE

extractTrain

logical. switch for set on extract training data according to training geometries default = TRUE

prefixRun

character. general prefix of all result files of the current run default = "tmp"

patterndemFiles

character. mandantory if DEM data is processes. prefix of current DEM default = "dem"

prefixTrainImg

character. potential string of characters that is used in the beginning of a shape file prefixTrainImg_SHAPEFILENAME_suffixTrainImg

prefixTrainGeom

character. potential string of characters that is used in the beginning of a shape file prefixTrainGeom_SHAPEFILENAME_suffixTrainGeom

suffixTrainImg

character. potential string of characters that is used in the beginning of a shape file prefixTrainImg_SHAPEFILENAME_suffixTrainImg

suffixTrainGeom

character. potential string of characters that is used in the beginning of a shape file prefixTrainGeom_SHAPEFILENAME_suffixTrainGeom

patternIdx

character. code string that will concatenated to the filename to identify the index file

patternImgFiles

character. mandantory string that exist in ech imagefile to be processes

channels

character. channels to be choosed options are c("red", "green", "blue") default = c("red", "green", "blue")

hara

logical. switch for using HaralickTextureExtraction, default = TRUE.

haraType

character. hara options, default is c("simple"), other options are "advanced" "higher" "all". NOTE: "higher" takes a LOT of time

stat

logical. switch for using statistic default = TRUE the stas are mean,variance, curtosis, skewness

edge

logical. switch for using edge filtering default = TRUE

edgeType

character. edge options, default is c("gradient","sobel","touzi") all options are c("gradient","sobel","touzi")

morpho

logical. switch for using morphological filtering default = TRUE

morphoType

character. morphological options, default is c("dilate","erode","opening","closing") all options are ("dilate","erode","opening","closing")

rgbi

logical. switch for using rgbi index calcualtions default = TRUE

indices

character. RGB indices, default is c("VARI","NDTI","RI","CI","BI","SI","HI","TGI","GLI","NGRDI") all options are c("VVI","VARI","NDTI","RI","SCI","BI","SI","HI","TGI","GLI","NGRDI","GRVI","GLAI","HUE","CI","SAT","SHP")

rgbTrans

logical. switch for using color space transforming default = TRUE

colorSpaces

character. RGB colorspace transforming to default c("CIELab","CMY","Gray","HCL","HSB","HSI","Log","XYZ","YUV")

pardem

logical. switch for calculating dem parameter, default = FALSE

demType

character. ("hillshade","slope", "aspect","TRI","TPI","Roughness")

morphoMethod

numeric. saga morphometric method

minScale

numeric. in scale for multi scale TPI

maxScale

numeric. max scale for multi scale TPI

numScale

numeric. number of scale for multi scale TPI

kernel

numeric. size of kernel for filtering and statistics, default is 3

currentDataFolder

NULL folder to image (and shape) data

currentIdxFolder

NULL folder for saving the results

cleanRunDir

logical. TRUE logical switch for deleting the calculated tifs, default is TRUE

sagaLinks

list. SAGA tools cli paths

gdalLinks

list. GDAL tools cli paths

otbLinks

list. OTB tools cli paths

Details

(01) calc_ext() calculation of spectral indices, basic spatial statistics and textures and extracting of training values over all channels according to training data

(02) ffs_train() training using random forest and the forward feature selection method
startTrain=TRUE

(03) calc_ext() with respect to the selected predictor variables you may calculate the requested channels for all rgb data that you want to predict.

(04) prediction startPredict=TRUE

Value

data frame containing for each drawn point the pixel values of the rasterstack data

Note

If the function is used for stand alone extraction of the training data please provide both, the imagestack containing the raster data plus the corresponding band names (usually saved as an Rdata file) and the corresponding shape file.

The workflow is intended to use the forward feature selection as decribed by Meyer et al. (2018). This approach needs at least a pair of images that differ in time and/or space for a leave one location out validation mode. You may overcome this situation if you tile your image and provide for each tile seperate training data. If you just want to classify a single image by a single training file use the normal procedure as provided by the trainControl function.

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
## Not run: 

require(uavRst)
require(link2GI)

# create and check the links to the GI software
sagaLinks<-link2GI::linkSAGA()
gdalLinks<-link2GI::linkGDAL()
otbLinks<-link2GI::linkOTB()


##- create and set folders
##- please mind that the pathes are exported as global variables
paths<-link2GI::initProj(projRootDir = tempdir(),
                         projFolders = c("data/","data/ref/","output/","run/","las/"),
                         global = TRUE,
                         path_prefix = "path_")
  
##- clean runtime folder
unlink(file.path(tempdir(),"*"), force = TRUE)
  
##- get the tutorial data
url<-"https://github.com/gisma/gismaData/raw/master/uavRst/data/tutorial_data.zip"
utils::download.file(url,
                       file.path(tempdir(),"tutorial_data.zip"))
unzip(zipfile = file.path(tempdir(),"tutorial_data.zip"), 
                          exdir = R.utils::getAbsolutePath(path_run))
  
  ##- calculate some synthetic channels from the RGB image and the canopy height model
  ##- then extract the from the corresponding training geometries the data values aka trainingdata
  trainDF <- calc_ext(calculateBands    = TRUE,
                      extractTrain      = TRUE,
                      suffixTrainGeom   = "",
                      patternIdx        = "index",
                      patternImgFiles   = "rgb" ,
                      patterndemFiles   = "chm",
                      prefixRun         = "tutorial",
                      prefixTrainImg    = "",
                      rgbi              = TRUE,
                      indices           = c("TGI","CI"),
                      channels          = c("red"),
                      rgbTrans          = TRUE,
                      hara              = TRUE,
                      haraType          = c("simple"),
                      stat              = TRUE,
                      edge              = TRUE,
                      morpho            = TRUE,
                      pardem            = TRUE,
                      #demType           = c("slope", "MTPI"),
                      kernel            = 3,
                      currentDataFolder = path_run,
                      currentIdxFolder  = path_run,
                      sagaLinks = sagaLinks,
                      gdalLinks = gdalLinks,
                      otbLinks =otbLinks)
  

##- show the result
head(trainDF)

# use ffs_train as next step for rf classification issues


## End(Not run)

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