make_syn_bands | R Documentation |
Convenient function to preprocess synthetic raster bands from a given RGB image and/or DTM/DSM data.
Currently for all channels of the input images the following textures and indices can be calculated:
RGB indices (17), color transformation (9), haralick (3 = 25 layers), statistics (4), edge (3), morphological (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 raster files. 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.
make_syn_bands( calculateBands = TRUE, prefixRun = "temp", patterndemFiles = "dem", prefixTrainImg = "", prefixTrainGeom = "", suffixTrainImg = "", suffixTrainGeom = "", prefixIdx = "index", patternImgFiles = "", channels = c("PCA_RGB"), 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"), pardem = FALSE, 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"), saga_morphoMethod = 6, minScale = 1, maxScale = 8, numScale = 2, kernel = seq(3, 9, 2), quiet = TRUE, currentDataFolder = NULL, currentIdxFolder = NULL, cleanRunDir = FALSE, sagaLinks = NULL, gdalLinks = NULL, otbLinks = NULL, path_run = NULL )
calculateBands |
logical. switch for set on calculation of syntheic bands and indices 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 |
prefixIdx |
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("PCA_RGBI","PCA_RGB", red", "green", "blue") default = c("PCA_RGBI") first principal component of the RGBI image stack |
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") |
pardem |
logical. switch for calculating dem parameter, default = FALSE |
demType |
character. ("hillshade","slope", "aspect","TRI","TPI","Roughness") |
saga_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 |
quiet |
returning system messages |
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 |
path_run |
list project pathes and more |
(01) make_syn_bands() calculation of spectral indices, basic spatial statistics and textures
(02) 30_extract_training_df_RS.R extracting of training values over all channels according to training data
(03) 50_RS_LLO_rf_classification.R training and prediction using random forest and the forward feature selection method
data frame containing for each drawn point the pixel values of the rasterstack data
If the function is used for stand alone extraction of the training data please provide both, the image stack 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 described 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 separate 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.
## 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 <- make_syn_bands(calculateBands = TRUE, suffixTrainGeom = "", prefixIdx = "index", patternImgFiles = "rgb" , patterndemFiles = "chm", prefixRun = "tutorial", prefixTrainImg = "", rgbi = TRUE, indices = c("TGI","CI"), channels = c("red"), 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) # use ffs_train as next step for rf classification issues ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.