From c4c900918dcbb245f8acabadc1f368901d290cae Mon Sep 17 00:00:00 2001 From: vwmaus Date: Mon, 5 Jun 2017 18:47:33 +0200 Subject: [PATCH] Fix test to show progress bar and to use new version of twdtwClassify --- examples/test_twdtw_raster_analysis.R | 16 ++++++++++------ tests/test_twdtw_raster_analysis.R | 13 ++++++++----- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/examples/test_twdtw_raster_analysis.R b/examples/test_twdtw_raster_analysis.R index fef763e..5628163 100644 --- a/examples/test_twdtw_raster_analysis.R +++ b/examples/test_twdtw_raster_analysis.R @@ -1,5 +1,5 @@ \dontrun{ - + # Example of TWDTW analysis using raster files library(dtwSat) library(caret) @@ -43,22 +43,22 @@ log_fun <- logisticWeight(-0.1, 50) # Run serial TWDTW analysis r_twdtw <- - twdtwApply(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'test') + twdtwApply(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'text') # or Run parallel TWDTW analysis -beginCluster(n = 4) +beginCluster() r_twdtw <- - twdtwApplyParallel(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'test') + twdtwApplyParallel(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'text') endCluster() # Plot TWDTW distances for the first year plot(r_twdtw, type = "distance", time.levels = 1) # Classify raster based on the TWDTW analysis -r_lucc <- twdtwClassify(r_twdtw, format = "GTiff", overwrite = TRUE) +r_lucc <- twdtwClassify(r_twdtw, progress = 'text') # Plot TWDTW classification results -plot(r_lucc, type = "classification") +plot(r_lucc, type = "map") # Assess classification twdtw_assess <- @@ -71,6 +71,9 @@ plot(twdtw_assess, type = "accuracy") # Plot area uncertainty plot(twdtw_assess, type = "area") +# Plot misclassified samples +plot(twdtw_assess, type = "map", samples = "incorrect") + # Get latex table with error matrix twdtwXtable(twdtw_assess, table.type = "matrix") @@ -81,3 +84,4 @@ twdtwXtable(twdtw_assess, table.type = "accuracy") twdtwXtable(twdtw_assess, table.type = "area") } + diff --git a/tests/test_twdtw_raster_analysis.R b/tests/test_twdtw_raster_analysis.R index dea9583..0060463 100644 --- a/tests/test_twdtw_raster_analysis.R +++ b/tests/test_twdtw_raster_analysis.R @@ -41,22 +41,22 @@ log_fun <- logisticWeight(-0.1, 50) # Run serial TWDTW analysis r_twdtw <- - twdtwApply(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'test') + twdtwApply(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'text') # or Run parallel TWDTW analysis -beginCluster(n = 4) +beginCluster() r_twdtw <- - twdtwApplyParallel(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'test') + twdtwApplyParallel(x = rts, y = temporal_patterns, weight.fun = log_fun, progress = 'text') endCluster() # Plot TWDTW distances for the first year plot(r_twdtw, type = "distance", time.levels = 1) # Classify raster based on the TWDTW analysis -r_lucc <- twdtwClassify(r_twdtw, format = "GTiff", overwrite = TRUE) +r_lucc <- twdtwClassify(r_twdtw, progress = 'text') # Plot TWDTW classification results -plot(r_lucc, type = "classification") +plot(r_lucc, type = "map") # Assess classification twdtw_assess <- @@ -69,6 +69,9 @@ plot(twdtw_assess, type = "accuracy") # Plot area uncertainty plot(twdtw_assess, type = "area") +# Plot misclassified samples +plot(twdtw_assess, type = "map", samples = "incorrect") + # Get latex table with error matrix twdtwXtable(twdtw_assess, table.type = "matrix")