Learn R Programming

dtwSat (version 0.2.8)

twdtwXtable: LaTeX table from accuracy metrics

Description

Creates LaTeX table from accuracy metrics

Usage

# S4 method for twdtwAssessment
twdtwXtable(
  object,
  table.type = "accuracy",
  show.prop = TRUE,
  category.name = NULL,
  category.type = NULL,
  rotate.col = FALSE,
  time.labels = NULL,
  caption = NULL,
  digits = 2,
  show.footnote = TRUE,
  ...
)

# S4 method for twdtwCrossValidation twdtwXtable( object, conf.int = 0.95, show.overall = TRUE, category.name = NULL, category.type = NULL, caption = NULL, digits = 2, show.footnote = TRUE, ... )

Arguments

object

an object of class twdtwAssessment.

table.type

Table type, 'accuracy' for User's and Producer's Accuracy, 'errormatrix' for error matrix, and 'area' for area and uncertainty. Default is 'accuracy'.

show.prop

If TRUE shows the estimated proportion of area. Used with table.type='accuracy'. Default is TRUE.

category.name

A character vector defining the class names. If NULL the class names in the object x are used. Default is NULL.

category.type

A character defining the categories type "numeric" or "letter", if NULL the class names are used. Default is NULL.

rotate.col

Rotate class column names in latex table. Default is FALSE.

time.labels

A character or numeric for the time period or NULL to include all classified periods. Default is NULL.

caption

The table caption.

digits

Number of digits to show.

show.footnote

Show confidence interval in the footnote.

...

Other arguments to pass to print.xtable.

conf.int

Specifies the confidence level (0-1).

show.overall

If TRUE shows the overall accuracy of the cross-validation. Default is TRUE.

Author

Victor Maus, vwmaus1@gmail.com

References

Maus:2019dtwSat

Maus:2016dtwSat

See Also

twdtwAssess and twdtwAssessment.

Examples

Run this code
if (FALSE) {

# Create raster time series
evi = brick(system.file("lucc_MT/data/evi.tif", package="dtwSat"))
ndvi = brick(system.file("lucc_MT/data/ndvi.tif", package="dtwSat"))
red = brick(system.file("lucc_MT/data/red.tif", package="dtwSat"))
blue = brick(system.file("lucc_MT/data/blue.tif", package="dtwSat"))
nir = brick(system.file("lucc_MT/data/nir.tif", package="dtwSat"))
mir = brick(system.file("lucc_MT/data/mir.tif", package="dtwSat"))
doy = brick(system.file("lucc_MT/data/doy.tif", package="dtwSat"))
timeline = scan(system.file("lucc_MT/data/timeline", package="dtwSat"), what="date")
rts = twdtwRaster(evi, ndvi, red, blue, nir, mir, timeline = timeline, doy = doy)

# Read field samples 
field_samples = read.csv(system.file("lucc_MT/data/samples.csv", package="dtwSat"))
proj_str = scan(system.file("lucc_MT/data/samples_projection", 
                package="dtwSat"), what = "character")

# Split samples for training (10%) and validation (90%) using stratified sampling 
library(caret) 
set.seed(1)
I = unlist(createDataPartition(field_samples$label, p = 0.1))
training_samples = field_samples[I,]
validation_samples = field_samples[-I,]

# Create temporal patterns 
training_ts = getTimeSeries(rts, y = training_samples, proj4string = proj_str)
temporal_patterns = createPatterns(training_ts, freq = 8, formula = y ~ s(x))

# Run TWDTW analysis for raster time series 
log_fun = weight.fun=logisticWeight(-0.1,50)
r_twdtw = twdtwApply(x=rts, y=temporal_patterns, weight.fun=log_fun, format="GTiff", 
                     overwrite=TRUE)
                     
# Classify raster based on the TWDTW analysis 
r_lucc = twdtwClassify(r_twdtw, format="GTiff", overwrite=TRUE)
plot(r_lucc)

# Assess classification 
twdtw_assess = twdtwAssess(object = r_lucc, y = validation_samples, 
                           proj4string = proj_str, conf.int=.95) 
twdtw_assess

# Create latex tables 
twdtwXtable(twdtw_assess, table.type="errormatrix", rotate.col=TRUE,
  caption="Error matrix", digits=2, comment=FALSE)
twdtwXtable(twdtw_assess, table.type="accuracy", category.type="letter", 
  caption="Accuracy metrics.")
twdtwXtable(twdtw_assess, table.type="area", category.type="letter",
  digits = 0, caption="Area and uncertainty")

}

Run the code above in your browser using DataLab