SampleSaturation: Sample Saturation Identification Tool

Description Usage Arguments Value Examples

View source: R/SampleSaturation.R

Description

This function aims to identify the number of samples required per class in order to get the highest accuracy results from a supervised classicifation.

Usage

1
2
SampleSaturation(img, model, trainData, valData, prodAcc, responseCol,
  nSamples, overall, plot_graph)

Arguments

img

A raster file.

model

The model which will be used for the classification. See train for model selection.

trainData

SpatialPolygonsDataFrame or SpatialPointsDataFrame containing the training locations.

valData

SpatialPolygonsDataFrame or SpatialPointsDataFrame containing the validation locations (optional). If no valData is given, the trainData will be split into 70 percent training and 30 percent validation.

prodAcc

TRUE or FALSE. If prodAcc is TRUE, the producer accuracy will be returned. If prodAcc is FALSE, the user accuracy will be returned.

responseCol

Character or integer giving the column in trainData, which contains the response variable.

nSamples

A vector containing the number of samples which will be used on the superClass function.

overall

TRUE or FALSE. Defines, whether the overall accuracy should be included or not.

plot_graph

TRUE or FALSE. Defines, whether the resulting data.frame should be automatically plotted or not.

Value

A data.frame with the accuracy numbers per class depending on the sample number.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(sp)
library(raster)
library(RStoolbox)
library(reshape2)
library(ggplot2)
library(randomForest)

# Load sample raster file
my_raster <- raster::brick(system.file(package = "superClassAnalysis", "extdata", "landsat_sample.tif"))

# Load sample training and validation data
my_train <- raster::shapefile(system.file(package = "superClassAnalysis", "extdata", "training_sample.shp"))
my_val <- raster::shapefile(system.file(package = "superClassAnalysis", "extdata", "validation_sample.shp"))

# Execute SampleSaturation function
x = SampleSaturation(img = my_raster, model = 'rf', trainData = my_train,
                     valData = my_val, nSamples = c(10, 50, 100, 500),
                     responseCol = "class_name", prodAcc = TRUE,
                     overall = TRUE, plot_graph = TRUE)

MBalthasar/superClassAnalysis documentation built on July 12, 2019, 12:53 a.m.