Description Usage Arguments Value Examples
View source: R/PolygonSaturation.R
This function aims to identify the best number of polygons required per class within a training data set in order to get the highest accuracy results from a supervised classicifation. It furthermore enables to identify polygons which lead to lower classification accuracies for training data quality testing. The function will always use the same number of polygons per class and is therefore limited by the class with the least amount of polygons. It is overall recommended to have the same number of polygons for each class. The function will start with 2 polygons per class.
1 2 | PolygonSaturation(img, model, trainData, valData, prodAcc, responseCol,
overall, plot_graph, nSamples)
|
img |
A raster file. |
model |
The model which will be used for the classification. See |
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 |
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. |
nSamples |
Integer. Number of samples per land cover class. |
A data.frame with the accuracy numbers per class depending on the number of polygons used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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 PolygonSaturation function
x = PolygonSaturation(img = my_raster, model = 'rf', trainData = my_train,
valData = my_val, nSamples = 100, responseCol = "class_name",
prodAcc = TRUE, overall = TRUE, plot_graph = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.