Description Usage Arguments Value Examples
View source: R/ResolutionSaturation.R
This function aims to identify the best spatial resolution required per class in order to get the highest accuracy results from a supervised classicifation.
1 2 | ResolutionSaturation(img, model, trainData, valData, prodAcc, responseCol,
resolutions, nSamples, overall, plot_graph)
|
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 |
resolutions |
A vector containing the spatial resolutions after which the input raster will be reprojected. |
nSamples |
Integer. Number of samples per land cover class. |
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. |
A data.frame with the accuracy numbers per class depending on the spatial resolution.
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 ResolutionSaturation function
x = ResolutionSaturation(img = my_raster, model = 'rf', trainData = my_train,
valData = my_val, resolutions = c(30, 50, 75, 100, 200),
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.