diff --git a/DESCRIPTION b/DESCRIPTION index 7c975a9..4212d6c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -56,7 +56,7 @@ LazyData: true RoxygenNote: 5.0.1 Collate: 'class-crossValidation.R' - 'class-twdtwAccuracy.R' + 'class-twdtwAssessment.R' 'class-twdtwTimeSeries.R' 'class-twdtwMatches.R' 'class-twdtwRaster.R' @@ -87,7 +87,7 @@ Collate: 'subset.R' 'twdtw.R' 'twdtwApply.R' - 'twdtwAssessment.R' + 'twdtwAssess.R' 'twdtwClassify.R' 'twdtwCrossValidation.R' 'zzz.R' diff --git a/NAMESPACE b/NAMESPACE index f2451ca..62d6337 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -53,6 +53,7 @@ exportMethods(nlayers) exportMethods(nrow) exportMethods(plot) exportMethods(projection) +exportMethods(projecttwdtwRaster) exportMethods(res) exportMethods(resampleTimeSeries) exportMethods(shiftDates) diff --git a/R/class-crossValidation.R b/R/class-crossValidation.R index cd28411..8e6dd5a 100644 --- a/R/class-crossValidation.R +++ b/R/class-crossValidation.R @@ -18,7 +18,7 @@ #' @aliases twdtwCrossValidation #' @author Victor Maus, \email{vwmaus1@@gmail.com} #' -#' @description This class stores the cross-validation. +#' @description This class stores the results of the cross-validation. #' #' @param object an object of class \code{\link[dtwSat]{twdtwTimeSeries}}. #' diff --git a/R/class-twdtwAccuracy.R b/R/class-twdtwAssessment.R similarity index 89% rename from R/class-twdtwAccuracy.R rename to R/class-twdtwAssessment.R index f5497a4..a38b528 100644 --- a/R/class-twdtwAccuracy.R +++ b/R/class-twdtwAssessment.R @@ -50,12 +50,18 @@ #' @section Slots : #' \describe{ #' \item{\code{accuracySummary}:}{Overall Accuracy, User's Accuracy, Produce's Accuracy, -#' and Error Matrix (confusion matrix) considering all time periods.} +#' Error Matrix (confusion matrix), and Estimated Area, considering all time periods.} #' \item{\code{accuracyByPeriod}:}{Overall Accuracy, User's Accuracy, Produce's Accuracy, -#' and Error Matrix (confusion matrix) for each time periods independently from each other.} +#' Error Matrix (confusion matrix), and Estimated Area, for each time periods independently +#' from each other.} #' \item{\code{data}:}{A \code{\link[base]{data.frame}} with period (from - to), reference labels, #' predicted labels, and other TWDTW information.} #' } +#' +#' @details +#' If the twdtwRaster is unprojected (longitude/latitude) the estimated area is sum of the approximate +#' surface area in km2 of each cell (pixel). If the twdtwRaster is projected the estimated area is calculated +#' using the the pixel resolution in the map unit. #' #' @examples #' \dontrun{ diff --git a/R/methods.R b/R/methods.R index e4882f5..27059a0 100644 --- a/R/methods.R +++ b/R/methods.R @@ -21,7 +21,7 @@ setGeneric("coverages", setGeneric("bands", function(x) standardGeneric("bands")) - + setGeneric("is.twdtwTimeSeries", function(x) standardGeneric("is.twdtwTimeSeries")) @@ -30,18 +30,21 @@ setGeneric("is.twdtwMatches", setGeneric("is.twdtwRaster", function(x) standardGeneric("is.twdtwRaster")) - + +setGeneric("projecttwdtwRaster", + function(x, ...) standardGeneric("projecttwdtwRaster")) + as.list.twdtwTimeSeries = function(x) lapply(seq_along(x), function(i) - new("twdtwTimeSeries", x[[i]], labels(x)[i]) ) + new("twdtwTimeSeries", x[[i]], labels(x)[i]) ) as.list.twdtwRaster = function(x) { - I = coverages(x) - names(I) = I - lapply(I, function(i) x[[i]]) - } + I = coverages(x) + names(I) = I + lapply(I, function(i) x[[i]]) +} as.list.twdtwMatches = function(x) lapply(seq_along(x@timeseries), function(i) - new("twdtwMatches", new("twdtwTimeSeries", x@timeseries[[i]], labels(x@timeseries)[i]), x@patterns, list(x@alignments[[i]])) ) + new("twdtwMatches", new("twdtwTimeSeries", x@timeseries[[i]], labels(x@timeseries)[i]), x@patterns, list(x@alignments[[i]])) ) dim.twdtwTimeSeries = function(x){ res = data.frame(as.character(labels(x)), t(sapply(x@timeseries, dim))) @@ -178,7 +181,7 @@ setMethod(f = "ncol", "twdtwRaster", #' @export setMethod(f = "nrow", "twdtwRaster", definition = nrow.twdtwRaster) - + #' @inheritParams twdtwRaster-class #' @rdname twdtwRaster-class #' @export @@ -204,26 +207,26 @@ setMethod(f = "layers", "twdtwRaster", #' @export setMethod(f = "coverages", "twdtwRaster", definition = coverages.twdtwRaster) - + #' @aliases bands #' @inheritParams twdtwRaster-class #' @rdname twdtwRaster-class #' @export setMethod(f = "bands", "twdtwRaster", definition = bands.twdtwRaster) - + #' @inheritParams twdtwRaster-class #' @rdname twdtwRaster-class #' @export setMethod(f = "names", "twdtwRaster", definition = names.twdtwRaster) - + #' @inheritParams twdtwRaster-class #' @rdname twdtwRaster-class #' @export setMethod(f = "index", "twdtwRaster", definition = index.twdtwRaster) - + #' @inheritParams twdtwTimeSeries-class #' @rdname twdtwTimeSeries-class #' @export @@ -235,13 +238,13 @@ setMethod(f = "index", "twdtwTimeSeries", #' @export setMethod(f = "index", "twdtwMatches", definition = index.twdtwMatches) - + #' @inheritParams twdtwTimeSeries-class #' @rdname twdtwTimeSeries-class #' @export setMethod(f = "nrow", "twdtwTimeSeries", definition = nrow.twdtwTimeSeries) - + #' @inheritParams twdtwTimeSeries-class #' @rdname twdtwTimeSeries-class #' @export @@ -253,7 +256,7 @@ setMethod(f = "ncol", "twdtwTimeSeries", #' @export setMethod(f = "length", signature = signature("twdtwRaster"), definition = length.twdtwRaster) - + #' @inheritParams twdtwTimeSeries-class #' @rdname twdtwTimeSeries-class #' @export @@ -344,8 +347,8 @@ setMethod("[", "twdtwMatches", function(x, i, j, drop=TRUE) { if(!drop) return(res) lapply(res, function(x){ res = do.call("rbind", lapply(seq_along(x), function(jj){ - data.frame(Alig.N=seq_along(x[[jj]]$distance),from=x[[jj]]$from, to=x[[jj]]$to, distance=x[[jj]]$distance, label=x[[jj]]$label, row.names=NULL) - })) + data.frame(Alig.N=seq_along(x[[jj]]$distance),from=x[[jj]]$from, to=x[[jj]]$to, distance=x[[jj]]$distance, label=x[[jj]]$label, row.names=NULL) + })) res[order(res$from),] }) }) @@ -376,7 +379,7 @@ setMethod("levels", "twdtwTimeSeries", #' @export setMethod("labels", signature = signature(object="twdtwRaster"), definition = function(object) as.character(object@labels)) - + #' @inheritParams twdtwMatches-class #' @rdname twdtwMatches-class #' @export @@ -441,22 +444,40 @@ show.twdtwRaster = function(object){ invisible(NULL) } +# Show objects of class twdtwAssessment +show.twdtwAssessment = function(object){ + cat("An object of class \"twdtwAssessment\"\n") + cat("Number of classification intervals:",length(object@accuracyByPeriod),"\n") + cat("Accuracy metrics summary\n") + cat("\nOverall\n") + print(object@accuracySummary$OverallAccuracy, digits=2) + cat("\nUsers\n") + print(object@accuracySummary$UsersAccuracy, digits=2) + cat("\nProducers\n") + print(object@accuracySummary$ProducersAccuracy, digits=2) + invisible(NULL) +} + # Show objects of class twdtwCrossValidation show.twdtwCrossValidation = function(object){ res = summary(object, conf.int=.95) - res = lapply(res, FUN=round, digits = 2) cat("An object of class \"twdtwCrossValidation\"\n") cat("Number of data partitions:",length(object@partitions),"\n") - cat("Bootstrap simulation (CI .95)\n") - print(res) + cat("Accuracy metrics using bootstrap simulation (CI .95)\n") + cat("\nOverall\n") + print(res$Overall, digits=2) + cat("\nUsers\n") + print(res$Users, digits=2) + cat("\nProducers\n") + print(res$Producers, digits=2) invisible(NULL) } -#' @inheritParams twdtwCrossValidation-class -#' @rdname twdtwCrossValidation-class -#' @export -setMethod(f = "show", "twdtwCrossValidation", - definition = show.twdtwCrossValidation) +# Project raster which belong to a twdtwRaster object +projecttwdtwRaster.twdtwRaster = function(x, to, ...){ + x@timeseries = lapply(x@timeseries, projectRaster, to, ...) + x +} summary.twdtwCrossValidation = function(object, conf.int=.95, ...){ @@ -474,16 +495,28 @@ summary.twdtwCrossValidation = function(object, conf.int=.95, ...){ names(l_names) = l_names ic_ov = mean_cl_boot(x = ov[, c("OV")], conf.int = conf.int, ...) names(ic_ov) = NULL - assess_ov = data.frame(OverallAccuracy=ic_ov[1], sd=sd_ov, CImin=ic_ov[2], CImax=ic_ov[3]) + assess_ov = data.frame(Accuracy=ic_ov[1], sd=sd_ov, CImin=ic_ov[2], CImax=ic_ov[3]) ic_ua = t(sapply(l_names, function(i) mean_cl_boot(x = uapa$UA[uapa$label==i], conf.int = conf.int, ...))) names(ic_ua) = NULL - assess_ua = data.frame(UsersAccuracy=unlist(ic_ua[,1]), sd=sd_uapa[,"UA"], CImin=unlist(ic_ua[,2]), CImax=unlist(ic_ua[,3])) + assess_ua = data.frame(Accuracy=unlist(ic_ua[,1]), sd=sd_uapa[,"UA"], CImin=unlist(ic_ua[,2]), CImax=unlist(ic_ua[,3])) ic_pa = t(sapply(l_names, function(i) mean_cl_boot(x = uapa$PA[uapa$label==i], conf.int = conf.int, ...))) names(ic_pa) = NULL - assess_pa = data.frame(ProducersAccuracy=unlist(ic_pa[,1]), sd=sd_uapa[,"PA"], CImin=unlist(ic_pa[,2]), CImax=unlist(ic_pa[,3])) - list(OverallAccuracy=assess_ov, UsersAccuracy=assess_ua, ProducersAccuracy=assess_pa) + assess_pa = data.frame(Accuracy=unlist(ic_pa[,1]), sd=sd_uapa[,"PA"], CImin=unlist(ic_pa[,2]), CImax=unlist(ic_pa[,3])) + list(Overall=assess_ov, Users=assess_ua, Producers=assess_pa) } +#' @inheritParams twdtwCrossValidation-class +#' @rdname twdtwCrossValidation-class +#' @export +setMethod(f = "show", "twdtwCrossValidation", + definition = show.twdtwCrossValidation) + +#' @inheritParams twdtwAssessment-class +#' @rdname twdtwAssessment-class +#' @export +setMethod(f = "show", "twdtwAssessment", + definition = show.twdtwAssessment) + #' @inheritParams twdtwCrossValidation-class #' @rdname twdtwCrossValidation-class #' @export @@ -507,7 +540,7 @@ setMethod(f = "show", "twdtwMatches", #' @export setMethod(f = "show", "twdtwRaster", definition = show.twdtwRaster) - + #' @aliases is.twdtwTimeSeries #' @inheritParams twdtwTimeSeries-class #' @describeIn twdtwTimeSeries Check if the object belongs to the class twdtwTimeSeries. @@ -521,7 +554,7 @@ setMethod("is.twdtwTimeSeries", "ANY", #' @export setMethod("is.twdtwMatches", "ANY", function(x) is(x, "twdtwMatches")) - + #' @aliases is.twdtwRaster #' @inheritParams twdtwRaster-class #' @describeIn twdtwRaster Check if the object belongs to the class twdtwRaster. @@ -529,5 +562,18 @@ setMethod("is.twdtwMatches", "ANY", setMethod("is.twdtwRaster", "ANY", function(x) is(x, "twdtwRaster")) +#' @aliases projecttwdtwRaster +#' @inheritParams twdtwRaster-class +#' @describeIn twdtwRaster project twdtwRaster object. +#' @param crs character or object of class 'CRS'. PROJ.4 description of +#' the coordinate reference system. For other arguments and more details see +#' \code{\link[raster]{projectRaster}}. +#' +#' @export +setMethod("projecttwdtwRaster", "twdtwRaster", + function(x, crs, ...) projecttwdtwRaster.twdtwRaster(x, crs, ...)) + + + diff --git a/R/twdtwAssessment.R b/R/twdtwAssess.R similarity index 92% rename from R/twdtwAssessment.R rename to R/twdtwAssess.R index b6eddb8..4fa9673 100644 --- a/R/twdtwAssessment.R +++ b/R/twdtwAssess.R @@ -6,10 +6,11 @@ setGeneric("twdtwAssess", #' @inheritParams twdtwAssessment-class #' @aliases twdtwAssess #' -#' @describeIn twdtwAssessment this function performs an accuracy assessment +#' @describeIn This function performs an accuracy assessment #' of the classified maps. The function returns Overall Accuracy, -#' User's Accuracy, Produce's Accuracy, and error matrix (confusion matrix) for -#' each time interval and a summary considering all classified intervals. +#' User's Accuracy, Produce's Accuracy, error matrix (confusion matrix), +#' and estimated area according to [1]. The function returns the metrics +#' for each time interval and a summary considering all classified intervals. #' #' @examples #' \dontrun{ @@ -52,7 +53,7 @@ setGeneric("twdtwAssess", #' #' # Assess classification #' twdtw_assess = twdtwAssess(r_lucc, validation_samples, proj4string=proj_str) -#' twdtw_assess@accuracySummary +#' twdtw_assess #' #' } #' @export @@ -219,22 +220,23 @@ twdtwAssess.twdtwRaster = function(object, y, labels, id.labels, proj4string, co } .getAreaByClass = function(l, r, rlevels, rnames){ - r = raster(r, layer = l) + r = raster(r, layer = l) if(isLonLat(r)){ + warning("Computing the approximate surface area in km2 of cells in an unprojected (longitude/latitude) Raster object. See ?raster::area", call. = TRUE) + # r = projectRaster(from = r, crs = proj_str, method = 'ngb') ra = area(r) I = lapply(rlevels, function(i) r[]==i ) out = sapply(I, function(i) sum(ra[i], na.rm = TRUE) ) names(out) = rnames - # stop("Not implemented yet. Please reproject the raster to equal area projection.") } else { - a = zonal(r, r, 'count') - I = match(a[,'zone'], rlevels) + npx = zonal(r, r, 'count') + I = match(npx[,'zone'], rlevels) out = rep(0, length(rnames)) names(out) = rnames - out[I] = a[,'count'] * prod(res(r)) + out[I] = npx[,'count'] * prod(res(r)) names(out) = rnames } - out + out } diff --git a/R/twdtwCrossValidation.R b/R/twdtwCrossValidation.R index 51baa61..d173c39 100644 --- a/R/twdtwCrossValidation.R +++ b/R/twdtwCrossValidation.R @@ -6,13 +6,14 @@ setGeneric("twdtwCrossValidation", #' @inheritParams twdtwCrossValidation-class #' @aliases twdtwCrossValidation #' -#' @describeIn twdtwCrossValidation Splits the set of time -#' series into training and validation. The function uses stratified -#' sampling and a simple random sampling for each stratum. For each data partition -#' this function performs a TWDTW analysis and returns the Overall Accuracy, -#' User's Accuracy, Produce's Accuracy, error matrix (confusion matrix), and a -#' \code{\link[base]{data.frame}} with the classification (Predicted), the -#' reference classes (Reference), and some TWDTW information. +#' @describeIn +#' Splits the set of time series into training and validation. +#' The function uses stratified sampling and a simple random sampling for +#' each stratum. For each data partition this function performs a TWDTW +#' analysis and returns the Overall Accuracy, User's Accuracy, Produce's Accuracy, +#' error matrix (confusion matrix), and a \code{\link[base]{data.frame}} with +#' the classification (Predicted), the reference classes (Reference), +#' and the results of the TWDTW analysis. #' #' @examples #' \dontrun{ @@ -49,6 +50,8 @@ setGeneric("twdtwCrossValidation", #' #' summary(cross_validation) #' +#' plot(cross_validation) +#' #' } #' @export setMethod(f = "twdtwCrossValidation", diff --git a/R/zzz.R b/R/zzz.R index 96a76dc..69ecaeb 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -18,7 +18,6 @@ utils::packageDescription("dtwSat")$Version) ) } - #' @import zoo #' @import raster #' @import ggplot2 diff --git a/man/MOD13Q1.MT.yearly.patterns.Rd b/man/MOD13Q1.MT.yearly.patterns.Rd deleted file mode 100644 index 97e2dba..0000000 --- a/man/MOD13Q1.MT.yearly.patterns.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\docType{data} -\name{MOD13Q1.MT.yearly.patterns} -\alias{MOD13Q1.MT.yearly.patterns} -\title{Data: patterns time series} -\format{A \link[dtwSat]{twdtwTimeSeries} object.} -\usage{ -MOD13Q1.MT.yearly.patterns -} -\description{ -This dataset has a list of patterns with the phenological cycle of: Water, -Cotton-Fallow, Forest, Low vegetation, Pasture, Soybean-Cotton, Soybean-Maize, Soybean-Millet, -Soybean-Sunflower, and Wetland. These time series are based on the MODIS product -MOD13Q1 250 m 16 days [1]. The patterns were build from ground truth samples of each -crop using Generalized Additive Models (GAM), see \link[dtwSat]{createPatterns}. -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\references{ -[1] Friedl MA, Sulla-Menashe D, Tan B, Schneider A, Ramankutty N, Sibley A, Huang X. (2010). -MODIS Collection 5 global land cover: Algorithm refinements and characterization of new -datasets. Remote Sensing of Environment, 114(1), 168 182. -} -\seealso{ -MOD13Q1 documentation: See -\url{https://lpdaac.usgs.gov/dataset_discovery/modis/modis_products_table/mod13q1}. -} -\keyword{datasets} - diff --git a/man/MOD13Q1.patterns.list.Rd b/man/MOD13Q1.patterns.list.Rd deleted file mode 100644 index 9fb8478..0000000 --- a/man/MOD13Q1.patterns.list.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\docType{data} -\name{MOD13Q1.patterns.list} -\alias{MOD13Q1.patterns.list} -\title{Data: patterns time series} -\format{A named \code{list} of 3 \link[zoo]{zoo} objects, ''Soybean'', ''Cotton'', -and ''Maize'', whose indices are \code{\link[base]{Dates}} in the format ''yyyy-mm-dd''. -Each node has 6 attributes: ''ndvi'', ''evi'', ''red'', ''nir'', ''blue'', -and ''mir''.} -\usage{ -MOD13Q1.patterns.list -} -\description{ -This dataset has a list of patterns with the phenological cycle of: Soybean, -Cotton, and Maize. These time series are based on the MODIS product -MOD13Q1 250 m 16 days [1]. The patterns were build from ground truth samples of each -crop using Generalized Additive Models (GAM), see \link[dtwSat]{createPatterns}. -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\references{ -[1] Friedl MA, Sulla-Menashe D, Tan B, Schneider A, Ramankutty N, Sibley A, Huang X. (2010). -MODIS Collection 5 global land cover: Algorithm refinements and characterization of new -datasets. Remote Sensing of Environment, 114(1), 168 182. -} -\seealso{ -\link[dtwSat]{MOD13Q1.ts}, -\link[dtwSat]{MOD13Q1.ts.list}, and -\link[dtwSat]{createPatterns}. - -MOD13Q1 documentation: See -\url{https://lpdaac.usgs.gov/dataset_discovery/modis/modis_products_table/mod13q1}. -} -\keyword{datasets} - diff --git a/man/MOD13Q1.ts.Rd b/man/MOD13Q1.ts.Rd deleted file mode 100644 index f608bc9..0000000 --- a/man/MOD13Q1.ts.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\docType{data} -\name{MOD13Q1.ts} -\alias{MOD13Q1.ts} -\title{Data: An example of satellite time series} -\format{A \link[zoo]{zoo} object, whose indices are \code{\link[base]{Dates}} -in the format ''yyyy-mm-dd''. Each node has 6 attributes: ''ndvi'', -''evi'', ''red'', ''nir'', ''blue'', and ''mir''.} -\usage{ -MOD13Q1.ts -} -\description{ -This dataset has a time series based on the -MODIS product MOD13Q1 250 m 16 days [1]. It is an irregularly sampled time series -using the real date of each pixel from ''2009-08-05'' to ''2013-07-31''. -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\references{ -[1] Friedl MA, Sulla-Menashe D, Tan B, Schneider A, Ramankutty N, Sibley A, Huang X. (2010). -MODIS Collection 5 global land cover: Algorithm refinements and characterization of new -datasets. Remote Sensing of Environment, 114(1), 168 182. -} -\seealso{ -\link[dtwSat]{MOD13Q1.ts.list}, -\link[dtwSat]{MOD13Q1.patterns.list}. - -MOD13Q1 documentation: -\url{https://lpdaac.usgs.gov/dataset_discovery/modis/modis_products_table/mod13q1}. -} -\keyword{datasets} - diff --git a/man/MOD13Q1.ts.labels.Rd b/man/MOD13Q1.ts.labels.Rd deleted file mode 100644 index 26389ee..0000000 --- a/man/MOD13Q1.ts.labels.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\docType{data} -\name{MOD13Q1.ts.labels} -\alias{MOD13Q1.ts.labels} -\title{Data: Labels of the satellite time series in MOD13Q1.ts} -\format{An object of class \link[base]{data.frame}, whose attributas are: -the label of the crop class ''label'', the start of the crop period ''from'', -and the end of the crop period ''to''. The dates are in the format ''yyyy-mm-dd''.} -\usage{ -MOD13Q1.ts.labels -} -\description{ -This labels are based on field work. -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\link[dtwSat]{MOD13Q1.ts}. -} -\keyword{datasets} - diff --git a/man/MOD13Q1.ts.list.Rd b/man/MOD13Q1.ts.list.Rd deleted file mode 100644 index c4de6ca..0000000 --- a/man/MOD13Q1.ts.list.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\docType{data} -\name{MOD13Q1.ts.list} -\alias{MOD13Q1.ts.list} -\title{Data: A list of satellite time series} -\format{A \link[zoo]{zoo} object, whose indices are \code{\link[base]{Dates}} -in the format ''yyyy-mm-dd''. Each node has 6 attributes: ''ndvi'', -''evi'', ''red'', ''nir'', ''blue'', and ''mir''.} -\usage{ -MOD13Q1.ts.list -} -\description{ -This dataset has a list of time series based on the -MODIS product MOD13Q1 250 m 16 days [1]. It is an irregularly sampled time series -using the real date of each pixel from ''2009-08-05'' to ''2013-07-31''. -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\references{ -[1] Friedl MA, Sulla-Menashe D, Tan B, Schneider A, Ramankutty N, Sibley A, Huang X. (2010). -MODIS Collection 5 global land cover: Algorithm refinements and characterization of new -datasets. Remote Sensing of Environment, 114(1), 168 182. -} -\seealso{ -\link[dtwSat]{MOD13Q1.ts}, and -\link[dtwSat]{MOD13Q1.patterns.list}. - -MOD13Q1 documentation: -\url{https://lpdaac.usgs.gov/dataset_discovery/modis/modis_products_table/mod13q1}. -} -\keyword{datasets} - diff --git a/man/createPatterns.Rd b/man/createPatterns.Rd deleted file mode 100644 index bcf71ce..0000000 --- a/man/createPatterns.Rd +++ /dev/null @@ -1,85 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/createPatterns.R -\docType{methods} -\name{createPatterns} -\alias{createPatterns} -\alias{createPatterns,twdtwTimeSeries-method} -\alias{createPatterns-twdtwMatches} -\title{Create patterns} -\usage{ -createPatterns(x, from = NULL, to = NULL, freq = 1, attr = NULL, - split = TRUE, formula, ...) - -\S4method{createPatterns}{twdtwTimeSeries}(x, from = NULL, to = NULL, - freq = 1, attr = NULL, split = TRUE, formula, ...) -} -\arguments{ -\item{x}{an object of class \code{\link[dtwSat]{twdtwTimeSeries}}.} - -\item{from}{A character or \code{\link[base]{Dates}} object in the format -"yyyy-mm-dd". If not informed it is equal to the smallest date of the -first element in x. See details.} - -\item{to}{A \code{\link[base]{character}} or \code{\link[base]{Dates}} -object in the format "yyyy-mm-dd". If not informed it is equal to the -greatest date of the first element in x. See details.} - -\item{freq}{An integer. The sampling frequency of the output patterns.} - -\item{attr}{A vector character or numeric. The attributes in \code{x} to be used. -If not declared the function uses all attributes.} - -\item{split}{A logical. If TRUE the samples are split by label. If FALSE -all samples are set to the same label.} - -\item{formula}{A formula. Argument to pass to \code{\link[mgcv]{gam}}.} - -\item{...}{other arguments to pass to the function \code{\link[mgcv]{gam}} in the -packege \pkg{mgcv}.} -} -\value{ -an object of class \code{\link[dtwSat]{twdtwTimeSeries}} -} -\description{ -Create temporal patterns from objects of class twdtwTimeSeries. -} -\details{ -The hidden assumption is that the temporal pattern is a cycle the repeats itself -within a given time interval. Therefore, all time series samples in \code{x} are aligned -to each other keeping their respective sequence of days of the year. The function fits a -Generalized Additive Model (GAM) to the aligned set of samples. -} -\examples{ -# Creating patterns from objects of class twdtwTimeSeries -evi = brick(system.file("lucc_MT/data/evi.tif", package="dtwSat")) -ndvi = brick(system.file("lucc_MT/data/ndvi.tif", package="dtwSat")) -timeline = scan(system.file("lucc_MT/data/timeline", package="dtwSat"), what="date") -rts = twdtwRaster(evi, ndvi, timeline=timeline) - -# Read field samples -\dontrun{ -field_samples = read.csv(system.file("lucc_MT/data/samples.csv", package="dtwSat")) -prj_string = scan(system.file("lucc_MT/data/samples_projection", package="dtwSat"), - what = "character") - -# Extract time series -ts = getTimeSeries(rts, y = field_samples, proj4string = prj_string) - -# Create temporal patterns -patt = createPatterns(x=ts, from="2005-09-01", to="2006-09-01", freq=8, formula = y~s(x)) - -# Plot patterns -autoplot(patt[[1]], facets = NULL) + xlab("Time") + ylab("Value") - -} -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwMatches-class}}, -\code{\link[dtwSat]{twdtwTimeSeries-class}}, -\code{\link[dtwSat]{getTimeSeries}}, and -\code{\link[dtwSat]{twdtwApply}} -} - diff --git a/man/dtwSat.Rd b/man/dtwSat.Rd deleted file mode 100644 index 8a9a3e7..0000000 --- a/man/dtwSat.Rd +++ /dev/null @@ -1,29 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/dwtSat.R -\name{dtwSat} -\alias{dtwSat} -\title{Time-Weighted Dynamic Time Warping for Satellite Image Time Series} -\description{ -Provides an implementation of the Time-Weighted Dynamic Time Warping -(TWDTW) method for land use and land cover mapping using satellite image time series [1]. -TWDTW is based on the Dynamic Time Warping technique and has achieved high accuracy -for land use and land cover classification using satellite data. The method is based -on comparing unclassified satellite image time series with a set of known temporal -patterns (e.g. phenological cycles associated with the vegetation). Using 'dtwSat' -the user can build temporal patterns for land cover types, apply the TWDTW analysis -for satellite datasets, visualize the results of the time series analysis, produce -land cover maps, and create temporal plots for land cover change analysis. -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\references{ -[1] Maus V, Camara G, Cartaxo R, Sanchez A, Ramos FM, de Queiroz, GR. -(2016). A Time-Weighted Dynamic Time Warping method for land use and land cover -mapping. Selected Topics in Applied Earth Observations and Remote Sensing, -IEEE Journal of, vol.PP, no.99, pp.1-11. -} -\seealso{ -\code{\link[dtwSat]{twdtwApply}} -} - diff --git a/man/get.Rd b/man/get.Rd deleted file mode 100644 index d72415c..0000000 --- a/man/get.Rd +++ /dev/null @@ -1,55 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/getInternals.R -\docType{methods} -\name{get} -\alias{get} -\alias{getAlignments} -\alias{getAlignments,twdtwMatches-method} -\alias{getInternals} -\alias{getInternals,twdtwMatches-method} -\alias{getMatches} -\alias{getMatches,twdtwMatches-method} -\title{Get elements from twdtwMatches objects} -\usage{ -\S4method{getAlignments}{twdtwMatches}(object, timeseries.labels = NULL, - patterns.labels = NULL) - -\S4method{getInternals}{twdtwMatches}(object, timeseries.labels = NULL, - patterns.labels = NULL) - -\S4method{getMatches}{twdtwMatches}(object, timeseries.labels = NULL, - patterns.labels = NULL) -} -\arguments{ -\item{object}{an object of class twdtwMatches.} - -\item{timeseries.labels}{a vector with labels of the time series.} - -\item{patterns.labels}{a vector with labels of the patterns.} -} -\value{ -a list with TWDTW results or an object \code{\link[dtwSat]{twdtwTimeSeries-class}}. -} -\description{ -Get elements from \code{\link[dtwSat]{twdtwMatches-class}} objects. -} -\examples{ -# Getting patterns from objects of class twdtwMatches -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -ts = twdtwTimeSeries(MOD13Q1.ts.list) -mat = twdtwApply(x=ts, y=patt, weight.fun=logisticWeight(-0.1,100), keep=TRUE) -getPatterns(mat) -getTimeSeries(mat) -getAlignments(mat) -getMatches(mat) -getInternals(mat) - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwMatches-class}}, and -\code{\link[dtwSat]{twdtwApply}} -} - diff --git a/man/getDatesFromDOY.Rd b/man/getDatesFromDOY.Rd deleted file mode 100644 index 2ca3e5f..0000000 --- a/man/getDatesFromDOY.Rd +++ /dev/null @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/miscellaneous.R -\docType{methods} -\name{getDatesFromDOY} -\alias{getDatesFromDOY} -\title{Get dates from year and day of the year} -\usage{ -getDatesFromDOY(year, doy) -} -\arguments{ -\item{year}{An vector with the years.} - -\item{doy}{An vector with the day of the year. -It must have the same lenght as \code{year}.} -} -\value{ -A \code{\link[base]{Dates}} object. -} -\description{ -This function retrieves the date corresponding to the ginven -year and day of the year. -} -\examples{ -year = c(2000, 2001) -doy = c(366, 365) -dates = getDatesFromDOY(year, doy) -dates - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\link[dtwSat]{shiftDates} -} - diff --git a/man/getTimeSeries.Rd b/man/getTimeSeries.Rd deleted file mode 100644 index 183ffba..0000000 --- a/man/getTimeSeries.Rd +++ /dev/null @@ -1,91 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/getTimeSeries.R -\docType{methods} -\name{getTimeSeries} -\alias{getPatterns} -\alias{getPatterns,twdtwMatches-method} -\alias{getPatterns-twdtwMatches} -\alias{getTimeSeries} -\alias{getTimeSeries,twdtwMatches-method} -\alias{getTimeSeries,twdtwRaster-method} -\alias{getTimeSeries,twdtwTimeSeries-method} -\alias{getTimeSeries-twdtwMatches} -\alias{getTimeSeries-twdtwRaster} -\alias{getTimeSeries-twdtwTimeSeries} -\title{Get time series from twdtw* objects} -\usage{ -\S4method{getTimeSeries}{twdtwTimeSeries}(object, labels = NULL) - -\S4method{getTimeSeries}{twdtwMatches}(object, labels = NULL) - -\S4method{getPatterns}{twdtwMatches}(object, labels = NULL) - -\S4method{getTimeSeries}{twdtwRaster}(object, y, labels = NULL, - proj4string = NULL, id.labels = NULL) -} -\arguments{ -\item{object}{an object of class of class twdtw*.} - -\item{labels}{character vector with time series labels. For signature -\code{\link[dtwSat]{twdtwRaster}} this argument can be used to set the -labels for each sample in \code{y}, or it can be combined with \code{id.labels} -to select samples with a specific label.} - -\item{y}{a \code{\link[base]{data.frame}} whose attributes are: longitude, -latitude, the start ''from'' and the end ''to'' of the time interval -for each sample. This can also be a \code{\link[sp]{SpatialPointsDataFrame}} -whose attributes are the start ''from'' and the end ''to'' of the time interval. -If missing ''from'' and/or ''to'', they are set to the time range of the -\code{object}.} - -\item{proj4string}{projection string, see \code{\link[sp]{CRS-class}}. Used -if \code{y} is a \code{\link[base]{data.frame}}.} - -\item{id.labels}{a numeric or character with an column name from \code{y} to -be used as samples labels. Optional.} -} -\value{ -An object of class \code{\link[dtwSat]{twdtwTimeSeries}}. - -a list with TWDTW results or an object \code{\link[dtwSat]{twdtwTimeSeries-class}}. -} -\description{ -Get time series from objects of class twdtw*. -} -\examples{ -# Getting time series from objects of class twdtwTimeSeries -ts = twdtwTimeSeries(MOD13Q1.ts.list) -getTimeSeries(ts, 2) -# Getting time series from objects of class twdtwTimeSeries -ts = twdtwTimeSeries(MOD13Q1.ts.list) -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -mat = twdtwApply(x=ts, y=patt) -getTimeSeries(mat, 2) -## This example creates a twdtwRaster object and extract time series from it. - -# Creating objects of class twdtwRaster with evi and ndvi time series -evi = brick(system.file("lucc_MT/data/evi.tif", package="dtwSat")) -ndvi = brick(system.file("lucc_MT/data/ndvi.tif", package="dtwSat")) -timeline = scan(system.file("lucc_MT/data/timeline", package="dtwSat"), what="date") -rts = twdtwRaster(evi, ndvi, timeline=timeline) - -# Location and time range -ts_location = data.frame(longitude = -55.96957, latitude = -12.03864, - from = "2007-09-01", to = "2013-09-01") -prj_string = "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0" - -## Extract time series -ts = getTimeSeries(rts, y = ts_location, proj4string = prj_string) - -autoplot(ts[[1]], facets = NULL) + xlab("Time") + ylab("Value") - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwRaster-class}}, -\code{\link[dtwSat]{twdtwTimeSeries-class}}, and -\code{\link[dtwSat]{twdtwMatches-class}} -} - diff --git a/man/linearWeight.Rd b/man/linearWeight.Rd deleted file mode 100644 index b5b3cee..0000000 --- a/man/linearWeight.Rd +++ /dev/null @@ -1,48 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/linearWeight.R -\docType{methods} -\name{linearWeight} -\alias{linearWeight} -\title{Linear weight function} -\usage{ -linearWeight(a, b = 0) -} -\arguments{ -\item{a}{numeric. The slop of the line.} - -\item{b}{numeric. The intercept of the line.} -} -\value{ -An \code{\link[base]{function}} object. -} -\description{ -Builds a linear time weight -function to compute the TWDTW local cost matrix [1]. -} -\details{ -The linear \code{linearWeight} and \code{logisticWeight} weight functions -can be passed to \code{\link[dtwSat]{twdtwApply}} through the argument \code{weight.fun}. -This will add a time-weight to the dynamic time warping analysis. The time weight -creates a global constraint useful to analyse time series with phenological cycles -of vegetation that are usually bound to seasons. In previous studies by [1] the -logistic weight had better results than the linear for land cover classification. -See [1] for details about the method. -} -\examples{ -lin_fun = linearWeight(a=0.1) -lin_fun - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\references{ -[1] Maus V, Camara G, Cartaxo R, Sanchez A, Ramos FM, de Queiroz, GR. -(2016). A Time-Weighted Dynamic Time Warping method for land use and land cover -mapping. Selected Topics in Applied Earth Observations and Remote Sensing, -IEEE Journal of, vol.PP, no.99, pp.1-11. -} -\seealso{ -\code{\link[dtwSat]{twdtwApply}} -} - diff --git a/man/logisticWeight.Rd b/man/logisticWeight.Rd deleted file mode 100644 index 980e169..0000000 --- a/man/logisticWeight.Rd +++ /dev/null @@ -1,48 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/logisticWeight.R -\docType{methods} -\name{logisticWeight} -\alias{logisticWeight} -\title{Logistic weight function} -\usage{ -logisticWeight(alpha, beta) -} -\arguments{ -\item{alpha}{numeric. The steepness of logistic weight.} - -\item{beta}{numeric. The midpoint of logistic weight.} -} -\value{ -An \code{\link[base]{function}} object. -} -\description{ -Builds a logistic time weight -function to compute the TWDTW local cost matrix [1]. -} -\details{ -The linear \code{linearWeight} and \code{logisticWeight} weight functions -can be passed to \code{\link[dtwSat]{twdtwApply}} through the argument \code{weight.fun}. -This will add a time-weight to the dynamic time warping analysis. The time weight -creates a global constraint useful to analyse time series with phenological cycles -of vegetation that are usually bound to seasons. In previous studies by [1] the -logistic weight had better results than the linear for land cover classification. -See [1] for details about the method. -} -\examples{ -log_fun = logisticWeight(alpha=-0.1, beta=100) -log_fun - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\references{ -[1] Maus V, Camara G, Cartaxo R, Sanchez A, Ramos FM, de Queiroz, GR. -(2016). A Time-Weighted Dynamic Time Warping method for land use and land cover -mapping. Selected Topics in Applied Earth Observations and Remote Sensing, -IEEE Journal of, vol.PP, no.99, pp.1-11. -} -\seealso{ -\code{\link[dtwSat]{twdtwApply}} -} - diff --git a/man/plot.Rd b/man/plot.Rd deleted file mode 100644 index 49c347f..0000000 --- a/man/plot.Rd +++ /dev/null @@ -1,64 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot.R -\docType{methods} -\name{plot} -\alias{plot} -\alias{plot,twdtwCrossValidation,ANY-method} -\alias{plot,twdtwMatches,ANY-method} -\alias{plot,twdtwRaster,ANY-method} -\alias{plot,twdtwTimeSeries,ANY-method} -\alias{plot-twdtwMatches} -\alias{plot-twdtwRaster} -\alias{plot-twdtwTimeSeries} -\title{Plotting twdtw* objects} -\usage{ -\S4method{plot}{twdtwCrossValidation,ANY}(x, type = "crossvalidation", ...) - -\S4method{plot}{twdtwTimeSeries,ANY}(x, type = "timeseries", ...) - -\S4method{plot}{twdtwMatches,ANY}(x, type = "alignments", ...) - -\S4method{plot}{twdtwRaster,ANY}(x, type = "maps", ...) -} -\arguments{ -\item{x}{An object of class twdtw*.} - -\item{type}{A character for the plot type: ''paths'', ''matches'', -''alignments'', ''classification'', ''cost'', ''patterns'', ''timeseries'', -''maps'', ''area'', ''changes'', and ''distance''.} - -\item{...}{additional arguments to pass to plotting functions. -\code{\link[dtwSat]{plotPaths}}, -\code{\link[dtwSat]{plotCostMatrix}}, -\code{\link[dtwSat]{plotAlignments}}, -\code{\link[dtwSat]{plotMatches}}, -\code{\link[dtwSat]{plotClassification}}, -\code{\link[dtwSat]{plotPatterns}}, -\code{\link[dtwSat]{plotTimeSeries}}, -\code{\link[dtwSat]{plotMaps}}, -\code{\link[dtwSat]{plotArea}}, or -\code{\link[dtwSat]{plotChanges}}.} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Methods for plotting objects of class twdtw*. -} -\details{ -\describe{ - \item{Plot types}{: - \cr\code{paths}: Method for plotting the minimum paths in the cost matrix of TWDTW. - \cr\code{matches}: Method for plotting the matching points from TWDTW analysis. - \cr\code{alignments}: Method for plotting the alignments and respective TWDTW dissimilarity measures. - \cr\code{classification}: Method for plotting the classification of each subinterval of the time series based on TWDTW analysis. - \cr\code{cost}: Method for plotting the internal matrices used during the TWDTW computation. - \cr\code{patterns}: Method for plotting the temporal patterns. - \cr\code{timeseries}: Method for plotting the temporal patterns. - } -} -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} - diff --git a/man/plotAlignments.Rd b/man/plotAlignments.Rd deleted file mode 100644 index 00a3c51..0000000 --- a/man/plotAlignments.Rd +++ /dev/null @@ -1,54 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotAlignments.R -\name{plotAlignments} -\alias{plotAlignments} -\title{Plotting alignments} -\usage{ -plotAlignments(x, timeseries.labels = NULL, patterns.labels = NULL, - attr = 1, threshold = Inf) -} -\arguments{ -\item{x}{An object of class \code{\link[dtwSat]{twdtwMatches}}.} - -\item{timeseries.labels}{the label or index of the time series. -Default is 1.} - -\item{patterns.labels}{a vector with labels of the patterns. If not -declared the function will plot the alignments for all patterna in \code{x}.} - -\item{attr}{An \link[base]{integer} or \link[base]{character} vector -indicating the attribute for plotting. Default is 1.} - -\item{threshold}{A number. The TWDTW dissimilarity threshold, \emph{i.e.} the -maximum TWDTW cost for consideration. Default is \code{Inf}.} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Method for plotting the alignments and TWDTW -dissimilarity measures. -} -\examples{ -log_fun = logisticWeight(-0.1, 100) -ts = twdtwTimeSeries(MOD13Q1.ts.list) -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun) - -plotAlignments(mat1) - -plotAlignments(mat1, attr=c("evi","ndvi")) - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwMatches-class}}, -\code{\link[dtwSat]{twdtwApply}}, -\code{\link[dtwSat]{plotPaths}}, -\code{\link[dtwSat]{plotCostMatrix}}, -\code{\link[dtwSat]{plotMatches}}, and -\code{\link[dtwSat]{plotClassification}}. -} - diff --git a/man/plotArea.Rd b/man/plotArea.Rd deleted file mode 100644 index 5a368fb..0000000 --- a/man/plotArea.Rd +++ /dev/null @@ -1,75 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotArea.R -\name{plotArea} -\alias{plotArea} -\title{Plotting maps} -\usage{ -plotArea(x, time.levels = NULL, time.labels = NULL, class.levels = NULL, - class.labels = NULL, class.colors = NULL) -} -\arguments{ -\item{x}{An object of class \code{\link[dtwSat]{twdtwRaster}}.} - -\item{time.levels}{A \link[base]{character} or \link[base]{numeric} -vector with the layers to plot. For plot type ''change'' the minimum length -is two.} - -\item{time.labels}{A \link[base]{character} or \link[base]{numeric} -vector with the labels of the layers. It must have the same -length as time.levels. Default is NULL.} - -\item{class.levels}{A \link[base]{character} or \link[base]{numeric} -vector with the levels of the raster values. Default is NULL.} - -\item{class.labels}{A \link[base]{character} or \link[base]{numeric} -vector with the labels of the raster values. It must have the same -length as class.levels. Default is NULL.} - -\item{class.colors}{a set of aesthetic values. It must have the same -length as class.levels. Default is NULL. See -\link[ggplot2]{scale_fill_manual} for details.} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Method for plotting time series of maps. -} -\examples{ -\dontrun{ -# Run TWDTW analysis for raster time series -patt = MOD13Q1.MT.yearly.patterns -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) - -time_interval = seq(from=as.Date("2007-09-01"), to=as.Date("2013-09-01"), - by="12 month") -log_fun = weight.fun=logisticWeight(-0.1,50) - -r_twdtw = twdtwApply(x=rts, y=patt, weight.fun=log_fun, breaks=time_interval, - filepath="~/test_twdtw", overwrite=TRUE, format="GTiff", mc.cores=3) - -r_lucc = twdtwClassify(r_twdtw, format="GTiff") - -plotArea(r_lucc) - -} -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwRaster-class}}, -\code{\link[dtwSat]{twdtwApply}}, -\code{\link[dtwSat]{plotMaps}}, -\code{\link[dtwSat]{plotChanges}}, and -\code{\link[dtwSat]{plotDistance}}. -} - diff --git a/man/plotChanges.Rd b/man/plotChanges.Rd deleted file mode 100644 index 800d047..0000000 --- a/man/plotChanges.Rd +++ /dev/null @@ -1,75 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotChanges.R -\name{plotChanges} -\alias{plotChanges} -\title{Plotting changes} -\usage{ -plotChanges(x, time.levels = NULL, time.labels = NULL, - class.levels = NULL, class.labels = NULL, class.colors = NULL) -} -\arguments{ -\item{x}{An object of class \code{\link[dtwSat]{twdtwRaster}}.} - -\item{time.levels}{A \link[base]{character} or \link[base]{numeric} -vector with the layers to plot. For plot type ''change'' the minimum length -is two.} - -\item{time.labels}{A \link[base]{character} or \link[base]{numeric} -vector with the labels of the layers. It must have the same -length as time.levels. Default is NULL.} - -\item{class.levels}{A \link[base]{character} or \link[base]{numeric} -vector with the levels of the raster values. Default is NULL.} - -\item{class.labels}{A \link[base]{character} or \link[base]{numeric} -vector with the labels of the raster values. It must have the same -length as class.levels. Default is NULL.} - -\item{class.colors}{a set of aesthetic values. It must have the same -length as class.levels. Default is NULL. See -\link[ggplot2]{scale_fill_manual} for details.} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Method for plotting changes over time. -} -\examples{ -\dontrun{ -# Run TWDTW analysis for raster time series -patt = MOD13Q1.MT.yearly.patterns -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) - -time_interval = seq(from=as.Date("2007-09-01"), to=as.Date("2013-09-01"), - by="12 month") -log_fun = weight.fun=logisticWeight(-0.1,50) - -r_twdtw = twdtwApply(x=rts, y=patt, weight.fun=log_fun, breaks=time_interval, - filepath="~/test_twdtw", overwrite=TRUE, format="GTiff") - -r_lucc = twdtwClassify(r_twdtw, format="GTiff", overwrite=TRUE) - -plotChanges(r_lucc) - -} -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwRaster-class}}, -\code{\link[dtwSat]{twdtwApply}}, -\code{\link[dtwSat]{plotArea}}, -\code{\link[dtwSat]{plotMaps}}, and -\code{\link[dtwSat]{plotDistance}}. -} - diff --git a/man/plotClassification.Rd b/man/plotClassification.Rd deleted file mode 100644 index 2e96699..0000000 --- a/man/plotClassification.Rd +++ /dev/null @@ -1,59 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotClassification.R -\name{plotClassification} -\alias{plotClassification} -\title{Plotting subintervals classification} -\usage{ -plotClassification(x, timeseries.labels = NULL, patterns.labels = NULL, - attr, ...) -} -\arguments{ -\item{x}{An object of class \code{\link[dtwSat]{twdtwMatches}}.} - -\item{timeseries.labels}{the label or index of the time series. -Default is 1.} - -\item{patterns.labels}{a vector with labels of the patterns. If not -declared the function will plot one alignment for each pattern.} - -\item{attr}{An \link[base]{integer} vector or \link[base]{character} vector -indicating the attribute for plotting. If not declared the function will plot -all attributes.} - -\item{...}{additional arguments passed to \code{\link[dtwSat]{twdtwClassify}}.} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Method for plotting the classification of each -subinterval of the time series based on TWDTW analysis. -} -\examples{ -log_fun = logisticWeight(-0.1, 100) -ts = twdtwTimeSeries(MOD13Q1.ts.list) -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun) - -# Classify interval -from = as.Date("2007-09-01") -to = as.Date("2013-09-01") -by = "6 month" -gp = plotClassification(x=mat1, from=from, to=to, by=by, overlap=.5) -gp - - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwMatches-class}}, -\code{\link[dtwSat]{twdtwApply}}, -\code{\link[dtwSat]{twdtwClassify}}, -\code{\link[dtwSat]{plotAlignments}}, -\code{\link[dtwSat]{plotPaths}}, -\code{\link[dtwSat]{plotMatches}}, and -\code{\link[dtwSat]{plotCostMatrix}}. -} - diff --git a/man/plotCostMatrix.Rd b/man/plotCostMatrix.Rd deleted file mode 100644 index db46c1a..0000000 --- a/man/plotCostMatrix.Rd +++ /dev/null @@ -1,54 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotCostMatrix.R -\name{plotCostMatrix} -\alias{plotCostMatrix} -\title{Plotting paths} -\usage{ -plotCostMatrix(x, timeseries.labels = NULL, patterns.labels = NULL, - matrix.name = "costMatrix") -} -\arguments{ -\item{x}{An object of class \code{\link[dtwSat]{twdtwMatches}}.} - -\item{timeseries.labels}{the label or index of the time series. -Default is 1.} - -\item{patterns.labels}{a vector with labels of the patterns. If not -declared the function will plot one alignment for each pattern.} - -\item{matrix.name}{A character. The name of the matrix to plot, -"costMatrix" for accumulated cost, "localMatrix" for local cost, -or "timeWeight" for time-weight. Default is "costMatrix".} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Method for plotting low cost paths in the TWDTW -cost matrix. -} -\examples{ -log_fun = logisticWeight(-0.1, 100) -ts = twdtwTimeSeries(MOD13Q1.ts.list) -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun, keep=TRUE) - -plotCostMatrix(mat1, matrix.name="costMatrix") - -plotCostMatrix(mat1, matrix.name="localMatrix") - -plotCostMatrix(mat1, matrix.name="timeWeight") - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwMatches-class}}, -\code{\link[dtwSat]{twdtwApply}}, -\code{\link[dtwSat]{plotAlignments}}, -\code{\link[dtwSat]{plotPaths}}, -\code{\link[dtwSat]{plotMatches}}, and -\code{\link[dtwSat]{plotClassification}}. -} - diff --git a/man/plotCrossValidation.Rd b/man/plotCrossValidation.Rd deleted file mode 100644 index 67815a0..0000000 --- a/man/plotCrossValidation.Rd +++ /dev/null @@ -1,66 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotCrossValidation.R -\name{plotCrossValidation} -\alias{plotCrossValidation} -\title{Plotting cross-validation} -\usage{ -plotCrossValidation(x, conf.int = 0.95) -} -\arguments{ -\item{x}{An object of class \code{\link[dtwSat]{plotCrossValidation}}.} - -\item{conf.int}{confidence level (0-1) for interval estimation of the population mean. -for details see \code{\link[Hmisc]{smean.cl.normal}}.} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Method for plotting cross-validation results. -} -\examples{ -\dontrun{ -# Data folder -data_folder = system.file("lucc_MT/data", package = "dtwSat") - -# Read dates -dates = scan(paste(data_folder,"timeline", sep = "/"), what = "dates") - -# Read raster time series -evi = brick(paste(data_folder,"evi.tif", sep = "/")) -raster_timeseries = twdtwRaster(evi, timeline = dates) - -# Read field samples -field_samples = read.csv(paste(data_folder,"samples.csv", sep = "/")) -table(field_samples[["label"]]) - -# Read field samples projection -proj_str = scan(paste(data_folder,"samples_projection", sep = "/"), - what = "character") - -# Get sample time series from raster time series -field_samples_ts = getTimeSeries(raster_timeseries, - y = field_samples, proj4string = proj_str) -field_samples_ts - -# Run cross validation -set.seed(1) -# Define TWDTW weight function -log_fun = logisticWeight(alpha=-0.1, beta=50) -cross_validation = twdtwCrossValidation(field_samples_ts, times=3, p=0.1, - freq = 8, formula = y ~ s(x, bs="cc"), weight.fun = log_fun) - -summary(cross_validation) - -plot(cross_validation, conf.int=.99) - -} - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwCrossValidation}} -} - diff --git a/man/plotDistance.Rd b/man/plotDistance.Rd deleted file mode 100644 index 8452998..0000000 --- a/man/plotDistance.Rd +++ /dev/null @@ -1,64 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotDistance.R -\name{plotDistance} -\alias{plotDistance} -\title{Plotting distance maps} -\usage{ -plotDistance(x, time.levels = 1, time.labels = 1, layers = NULL) -} -\arguments{ -\item{x}{An object of class \code{\link[dtwSat]{twdtwRaster}}.} - -\item{time.levels}{A \link[base]{character} or \link[base]{numeric} -vector with the layers to plot. For plot type ''change'' the minimum length -is two.} - -\item{time.labels}{A \link[base]{character} or \link[base]{numeric} -vector with the labels of the layers. It must have the same -length as time.levels. Default is NULL.} - -\item{layers}{A \link[base]{character} or \link[base]{numeric} -vector with the layers/bands of the raster time series.} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Method for plotting TWDTW distance maps. -} -\examples{ -\dontrun{ -# Run TWDTW analysis for raster time series -patt = MOD13Q1.MT.yearly.patterns -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) - -time_interval = seq(from=as.Date("2007-09-01"), to=as.Date("2013-09-01"), - by="12 month") -log_fun = weight.fun=logisticWeight(-0.1,50) - -r_twdtw = twdtwApply(x=rts, y=patt, weight.fun=log_fun, breaks=time_interval, - filepath="~/test_twdtw", overwrite=TRUE, format="GTiff", mc.cores=3) - -plotDistance(r_twdtw) - -} -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwRaster-class}}, -\code{\link[dtwSat]{twdtwApply}}, -\code{\link[dtwSat]{plotArea}}, -\code{\link[dtwSat]{plotChanges}}, and -\code{\link[dtwSat]{plotDistance}}. -} - diff --git a/man/plotMaps.Rd b/man/plotMaps.Rd deleted file mode 100644 index e28a2ee..0000000 --- a/man/plotMaps.Rd +++ /dev/null @@ -1,75 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotMaps.R -\name{plotMaps} -\alias{plotMaps} -\title{Plotting maps} -\usage{ -plotMaps(x, time.levels = NULL, time.labels = NULL, class.levels = NULL, - class.labels = NULL, class.colors = NULL) -} -\arguments{ -\item{x}{An object of class \code{\link[dtwSat]{twdtwRaster}}.} - -\item{time.levels}{A \link[base]{character} or \link[base]{numeric} -vector with the layers to plot. For plot type ''change'' the minimum length -is two.} - -\item{time.labels}{A \link[base]{character} or \link[base]{numeric} -vector with the labels of the layers. It must have the same -length as time.levels. Default is NULL.} - -\item{class.levels}{A \link[base]{character} or \link[base]{numeric} -vector with the levels of the raster values. Default is NULL.} - -\item{class.labels}{A \link[base]{character} or \link[base]{numeric} -vector with the labels of the raster values. It must have the same -length as class.levels. Default is NULL.} - -\item{class.colors}{a set of aesthetic values. It must have the same -length as class.levels. Default is NULL. See -\link[ggplot2]{scale_fill_manual} for details.} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Method for plotting time series of maps. -} -\examples{ -\dontrun{ -# Run TWDTW analysis for raster time series -patt = MOD13Q1.MT.yearly.patterns -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) - -time_interval = seq(from=as.Date("2007-09-01"), to=as.Date("2013-09-01"), - by="12 month") -log_fun = weight.fun=logisticWeight(-0.1,50) - -r_twdtw = twdtwApply(x=rts, y=patt, weight.fun=log_fun, breaks=time_interval, - filepath="~/test_twdtw", overwrite=TRUE, format="GTiff", mc.cores=3) - -r_lucc = twdtwClassify(r_twdtw, format="GTiff", overwrite=TRUE) - -plotMaps(r_lucc) - -} -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwRaster-class}}, -\code{\link[dtwSat]{twdtwApply}}, -\code{\link[dtwSat]{plotArea}}, -\code{\link[dtwSat]{plotChanges}}, and -\code{\link[dtwSat]{plotDistance}}. -} - diff --git a/man/plotMatches.Rd b/man/plotMatches.Rd deleted file mode 100644 index a916014..0000000 --- a/man/plotMatches.Rd +++ /dev/null @@ -1,65 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotMatches.R -\docType{methods} -\name{plotMatches} -\alias{plotMatches} -\title{Plotting matching points} -\usage{ -plotMatches(x, timeseries.labels = 1, patterns.labels = NULL, k = 1, - attr = 1, shift = 0.5, show.dist = FALSE) -} -\arguments{ -\item{x}{An object of class \code{\link[dtwSat]{twdtwMatches}}.} - -\item{timeseries.labels}{the label or index of the time series. -Default is 1.} - -\item{patterns.labels}{a vector with labels of the patterns. If not -declared the function will plot one alignment for each pattern.} - -\item{k}{A positive integer. The index of the last alignment to include in -the plot. If not declared the function will plot the best match for -each pattern.} - -\item{attr}{An \link[base]{integer} or \link[base]{character} vector -indicating the attribute for plotting. Default is 1.} - -\item{shift}{A number, it shifts the pattern position in the \code{x} -direction. Default is 0.5.} - -\item{show.dist}{show the distance for each alignment. Default is FALSE.} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Method for plotting the matching points from -TWDTW analysis. -} -\examples{ -log_fun = logisticWeight(-0.1, 100) -ts = twdtwTimeSeries(MOD13Q1.ts.list) -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun, keep=TRUE) - -plotMatches(mat1) - -plotMatches(mat1, patterns.labels="Soybean", k=4) - -plotMatches(mat1, patterns.labels=c("Soybean","Maize"), k=4) - -plotMatches(mat1, patterns.labels=c("Soybean","Cotton"), k=c(3,1)) - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwMatches-class}}, -\code{\link[dtwSat]{twdtwApply}}, -\code{\link[dtwSat]{plotPaths}}, -\code{\link[dtwSat]{plotCostMatrix}}, -\code{\link[dtwSat]{plotAlignments}}, and -\code{\link[dtwSat]{plotClassification}}. -} - diff --git a/man/plotPaths.Rd b/man/plotPaths.Rd deleted file mode 100644 index 469c648..0000000 --- a/man/plotPaths.Rd +++ /dev/null @@ -1,52 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotPaths.R -\name{plotPaths} -\alias{plotPaths} -\title{Plotting paths} -\usage{ -plotPaths(x, timeseries.labels = NULL, patterns.labels = NULL, k = NULL) -} -\arguments{ -\item{x}{An object of class \code{\link[dtwSat]{twdtwMatches}}.} - -\item{timeseries.labels}{the label or index of the time series. -Default is 1.} - -\item{patterns.labels}{a vector with labels of the patterns. If not -declared the function will plot one alignment for each pattern.} - -\item{k}{A positive integer. The index of the last alignment to include in -the plot. If not declared the function will plot all low cost paths.} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Method for plotting low cost paths in the TWDTW -cost matrix. -} -\examples{ -log_fun = logisticWeight(-0.1, 100) -ts = twdtwTimeSeries(MOD13Q1.ts.list) -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun, keep=TRUE) - -plotPaths(mat1) - -plotPaths(mat1, patterns.labels="Soybean", k=1:2) - -plotPaths(mat1, patterns.labels=c("Maize","Cotton"), k=2) - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwMatches-class}}, -\code{\link[dtwSat]{twdtwApply}}, -\code{\link[dtwSat]{plotAlignments}}, -\code{\link[dtwSat]{plotCostMatrix}}, -\code{\link[dtwSat]{plotMatches}}, and -\code{\link[dtwSat]{plotClassification}}. -} - diff --git a/man/plotPatterns.Rd b/man/plotPatterns.Rd deleted file mode 100644 index c285d45..0000000 --- a/man/plotPatterns.Rd +++ /dev/null @@ -1,42 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotPatterns.R -\name{plotPatterns} -\alias{plotPatterns} -\title{Plotting temporal patterns} -\usage{ -plotPatterns(x, labels = NULL, attr, year = 2005) -} -\arguments{ -\item{x}{An object of class \code{\link[dtwSat]{twdtwTimeSeries}}, -\code{\link[zoo]{zoo}}, or list of \code{\link[zoo]{zoo}}.} - -\item{labels}{a vector with labels of the time series. If not declared -the function will plot all time series.} - -\item{attr}{An \link[base]{integer} vector or \link[base]{character} vector -indicating the attribute for plotting. If not declared the function will plot -all attributes.} - -\item{year}{An integer. The base year to shift the dates of the time series to. -If NULL then it does not shif the time series. Default is 2005.} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Method for plotting the temporal patterns. -} -\examples{ -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -plotPatterns(patt) -plotPatterns(patt, attr="evi") - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwTimeSeries-class}} and -\code{\link[dtwSat]{plotTimeSeries}} -} - diff --git a/man/plotTimeSeries.Rd b/man/plotTimeSeries.Rd deleted file mode 100644 index c48ee23..0000000 --- a/man/plotTimeSeries.Rd +++ /dev/null @@ -1,39 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plotTimeSeries.R -\name{plotTimeSeries} -\alias{plotTimeSeries} -\title{Plotting time series} -\usage{ -plotTimeSeries(x, labels = NULL, attr) -} -\arguments{ -\item{x}{An object of class \code{\link[dtwSat]{twdtwTimeSeries}}, -\code{\link[zoo]{zoo}}, or list of \code{\link[zoo]{zoo}}.} - -\item{labels}{a vector with labels of the time series. If missing, all -elements in the list will be plotted (up to a maximum of 16).} - -\item{attr}{An \link[base]{integer} vector or \link[base]{character} vector -indicating the attribute for plotting. If not declared the function will plot -all attributes.} -} -\value{ -A \link[ggplot2]{ggplot} object. -} -\description{ -Method for plotting the temporal patterns. -} -\examples{ -ts = twdtwTimeSeries(MOD13Q1.ts.list) -plotTimeSeries(ts) -plotTimeSeries(ts, attr="evi") - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwTimeSeries-class}} and -\code{\link[dtwSat]{plotPatterns}} -} - diff --git a/man/reexports.Rd b/man/reexports.Rd deleted file mode 100644 index b656e63..0000000 --- a/man/reexports.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/zzz.R -\docType{import} -\name{reexports} -\alias{asymmetric} -\alias{rabinerJuangStepPattern} -\alias{reexports} -\alias{symmetric1} -\alias{symmetric2} -\title{Objects exported from other packages} -\description{ -These objects are imported from other packages. Follow the links -below to see their documentation. - -\describe{ - \item{dtw}{\code{\link[dtw]{symmetric1}}, \code{\link[dtw]{symmetric2}}, \code{\link[dtw]{asymmetric}}, \code{\link[dtw]{rabinerJuangStepPattern}}} -}} -\keyword{internal} - diff --git a/man/resampleTimeSeries.Rd b/man/resampleTimeSeries.Rd deleted file mode 100644 index 4edac62..0000000 --- a/man/resampleTimeSeries.Rd +++ /dev/null @@ -1,43 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resampleTimeSeries.R -\docType{methods} -\name{resampleTimeSeries} -\alias{resampleTimeSeries} -\alias{resampleTimeSeries,twdtwTimeSeries-method} -\alias{resampleTimeSeries-twdtwMatches} -\title{Resample time series} -\usage{ -resampleTimeSeries(object, length = NULL) - -\S4method{resampleTimeSeries}{twdtwTimeSeries}(object, length = NULL) -} -\arguments{ -\item{object}{an object of class twdtwTimeSeries.} - -\item{length}{An integer. The number of samples to resample the time series. -If not declared the length is set to the length of the longest time series.} -} -\value{ -An object of class \code{\link[dtwSat]{twdtwTimeSeries}} whose -time series have the same number of samples (points). -} -\description{ -resample time series in the same object to have the same -the length. -} -\examples{ -# Resampling time series from objects of class twdtwTimeSeries -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -npatt = resampleTimeSeries(patt, length=46) -nrow(patt) -nrow(npatt) - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwTimeSeries-class}}, and -\code{\link[dtwSat]{twdtwApply}} -} - diff --git a/man/shiftDates.Rd b/man/shiftDates.Rd deleted file mode 100644 index 76d33e0..0000000 --- a/man/shiftDates.Rd +++ /dev/null @@ -1,48 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/miscellaneous.R -\docType{methods} -\name{shiftDates} -\alias{shiftDates} -\alias{shiftDates,list-method} -\alias{shiftDates,twdtwTimeSeries-method} -\alias{shiftDates,zoo-method} -\alias{shiftDates-list} -\alias{shiftDates-twdtwTimeSeries} -\alias{shiftDates-zoo} -\title{Shift dates} -\usage{ -shiftDates(object, year = NULL) - -\S4method{shiftDates}{twdtwTimeSeries}(object, year = NULL) - -\S4method{shiftDates}{list}(object, year = NULL) - -\S4method{shiftDates}{zoo}(object, year = NULL) -} -\arguments{ -\item{object}{\code{\link[dtwSat]{twdtwTimeSeries}} objects, -\code{\link[zoo]{zoo}} objects or a list of \code{\link[zoo]{zoo}} objects.} - -\item{year}{the base year to shit the time series.} -} -\value{ -An object of the same class as the input \code{object}. -} -\description{ -This function shifts the dates of the time series to a -given base year. -} -\examples{ -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -npatt = shiftDates(patt, year=2005) -index(patt) -index(npatt) - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwTimeSeries-class}} -} - diff --git a/man/subset.Rd b/man/subset.Rd deleted file mode 100644 index 0b393f2..0000000 --- a/man/subset.Rd +++ /dev/null @@ -1,84 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/subset.R -\docType{methods} -\name{subset} -\alias{subset} -\alias{subset,twdtwMatches-method} -\alias{subset,twdtwRaster-method} -\alias{subset,twdtwTimeSeries-method} -\alias{subset-twdtwMatches} -\alias{subset-twdtwRaster} -\alias{subset-twdtwTimeSeries} -\title{Subset time series} -\usage{ -\S4method{subset}{twdtwTimeSeries}(x, labels = NULL) - -\S4method{subset}{twdtwMatches}(x, timeseries.labels = NULL, - patterns.labels = NULL, k = NULL) - -\S4method{subset}{twdtwRaster}(x, e = NULL, layers = NULL) -} -\arguments{ -\item{x}{An objects of class twdtw*.} - -\item{labels}{character vector with time series labels.} - -\item{timeseries.labels}{a vector with labels of the time series.} - -\item{patterns.labels}{a vector with labels of the patterns.} - -\item{k}{A positive integer. The index of the last alignment to include in -the subset.} - -\item{e}{An extent object, or any object from which an Extent object can -be extracted. See \link[raster]{crop} for details.} - -\item{layers}{a vector with the names of the \code{twdtwRaster} object to include in -the subset.} -} -\value{ -an object of class twdtw*. -} -\description{ -Get subsets from objects of class twdtw*. -} -\examples{ -# Getting time series from objects of class twdtwTimeSeries -ts = twdtwTimeSeries(MOD13Q1.ts.list) -ts = subset(ts, 2) -ts -# Getting time series from objects of class twdtwTimeSeries -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -mat = twdtwApply(x=ts, y=patt, weight.fun=logisticWeight(-0.1,100)) -mat = subset(mat, k=4) - -## This example creates a twdtwRaster object and extract time series from it. - -# Creating objects of class twdtwRaster with evi and ndvi time series -evi = brick(system.file("lucc_MT/data/evi.tif", package="dtwSat")) -ndvi = brick(system.file("lucc_MT/data/ndvi.tif", package="dtwSat")) -timeline = scan(system.file("lucc_MT/data/timeline", package="dtwSat"), what="date") -rts = twdtwRaster(evi, ndvi, timeline=timeline) - -rts_evi = subset(rts, layers="evi") - -field_samples = read.csv(system.file("lucc_MT/data/samples.csv", package="dtwSat")) -prj_string = scan(system.file("lucc_MT/data/samples_projection", package="dtwSat"), - what = "character") - -# Extract time series -ts_evi = getTimeSeries(rts_evi, y = field_samples, proj4string = prj_string) - -# subset all labels = "Forest" -ts_forest = subset(ts_evi, labels="Forest") - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwRaster-class}}, -\code{\link[dtwSat]{twdtwTimeSeries-class}}, and -\code{\link[dtwSat]{twdtwMatches-class}} -} - diff --git a/man/twdtwApply.Rd b/man/twdtwApply.Rd deleted file mode 100644 index 9d2ec01..0000000 --- a/man/twdtwApply.Rd +++ /dev/null @@ -1,175 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/twdtwApply.R -\docType{methods} -\name{twdtwApply} -\alias{twdtwApply} -\alias{twdtwApply,twdtwRaster-method} -\alias{twdtwApply,twdtwTimeSeries-method} -\alias{twdtwApply-twdtwRaster} -\alias{twdtwApply-twdtwTimeSeries} -\title{Apply TWDTW analysis} -\usage{ -twdtwApply(x, y, resample = TRUE, length = NULL, weight.fun = NULL, - dist.method = "Euclidean", step.matrix = symmetric1, n = NULL, - span = NULL, min.length = 0.5, theta = 0.5, ...) - -\S4method{twdtwApply}{twdtwTimeSeries}(x, y, resample, length, weight.fun, - dist.method, step.matrix, n, span, min.length, theta, keep = FALSE, ...) - -\S4method{twdtwApply}{twdtwRaster}(x, y, resample, length, weight.fun, - dist.method, step.matrix, n, span, min.length, theta, breaks = NULL, - from = NULL, to = NULL, by = NULL, overlap = 0.5, chunk.size = 1000, - filepath = NULL, ...) -} -\arguments{ -\item{x}{an object of class twdtw*. This is the target time series. -Usually, it is a set of unclassified time series.} - -\item{y}{an object of class \link[dtwSat]{twdtwTimeSeries}. -The temporal patterns.} - -\item{resample}{resample the patterns to have the same length. Default is TRUE. -See \link[dtwSat]{resampleTimeSeries} for details.} - -\item{length}{An integer. Patterns length used with \code{patterns.length}. -If not declared the length of the output patterns will be the length of -the longest pattern.} - -\item{weight.fun}{A function. Any function that receive and performs a -computation on a matrix. The function receives a matrix of time differences -in days and returns a matrix of time-weights. If not declared the time-weight -is zero. In this case the function runs the standard version of the dynamic -time warping. See details.} - -\item{dist.method}{A character. Method to derive the local cost matrix. -Default is ''Euclidean'' see \code{\link[proxy]{dist}} in package -\pkg{proxy}.} - -\item{step.matrix}{see \code{\link[dtw]{stepPattern}} in package \pkg{dtw} [2].} - -\item{n}{An integer. The maximun number of matches to perform. -NULL will return all matches.} - -\item{span}{A number. Span between two matches, \emph{i.e.} the minimum -interval between two matches, for details see [3]. If not declared it removes -all overlapping matches of the same pattern. To include overlapping matches -of the same pattern use \code{span=0}.} - -\item{min.length}{A number between 0 an 1. This argument removes the over fittings. -Minimum length after warping. Percentage of the original pattern length. Default is 0.5, -meaning that the matching cannot be shorter than half of the pattern length.} - -\item{theta}{numeric between 0 and 1. The weight of the time -for the TWDTW computation. Use \code{theta=0} to cancel the time-weight, -\emph{i.e.} to run the original DTW algorithm. Default is 0.5, meaning that -the time has the same weight as the curve shape in the TWDTW analysis.} - -\item{...}{arguments to pass to \code{\link[raster]{writeRaster}}} - -\item{keep}{preserves the cost matrix, inputs, and other internal structures. -Default is FALSE. For plot methods use \code{keep=TRUE}.} - -\item{breaks}{A vector of class \code{\link[base]{Dates}}. This replaces the arguments \code{from}, -\code{to}, and \code{by}.} - -\item{from}{A character or \code{\link[base]{Dates}} object in the format "yyyy-mm-dd".} - -\item{to}{A \code{\link[base]{character}} or \code{\link[base]{Dates}} object in the format "yyyy-mm-dd".} - -\item{by}{A \code{\link[base]{character}} with the intevals size, \emph{e.g.} "6 month".} - -\item{overlap}{A number between 0 and 1. The minimum overlapping -between one match and the interval of classification. Default is 0.5, -\emph{i.e.} an overlap minimum of 50\%.} - -\item{chunk.size}{An integer. Set the number of cells for each block, -see \code{\link[raster]{blockSize}} for details.} - -\item{filepath}{A character. The path to save the raster with results. If not informed the -function saves in the current work directory.} -} -\value{ -An object of class twdtw*. -} -\description{ -This function performs a multidimensional Time-Weighted DTW -analysis and retrieves the matches between the temporal patterns and -a set of time series [1]. -} -\details{ -The linear \code{linearWeight} and \code{logisticWeight} weight functions -can be passed to \code{twdtwApply} through the argument \code{weight.fun}. This will -add a time-weight to the dynamic time warping analysis. The time weight -creates a global constraint useful to analyse time series with phenological cycles -of vegetation that are usually bound to seasons. In previous studies by [1] the -logistic weight had better results than the linear for land cover classification. -See [1] for details about the method. -} -\examples{ -# Applying TWDTW analysis to objects of class twdtwTimeSeries -log_fun = logisticWeight(-0.1, 100) -ts = twdtwTimeSeries(MOD13Q1.ts.list) -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun) -mat1 - -\dontrun{ -# Parallel processin -require(parallel) -mat_list = mclapply(as.list(ts), mc.cores=2, FUN=twdtwApply, y=patt, weight.fun=log_fun) -mat2 = twdtwMatches(alignments=mat_list) -} -\dontrun{ -# Run TWDTW analysis for raster time series -patt = MOD13Q1.MT.yearly.patterns -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) - -time_interval = seq(from=as.Date("2007-09-01"), to=as.Date("2013-09-01"), - by="12 month") -log_fun = weight.fun=logisticWeight(-0.1,50) - -r_twdtw = twdtwApply(x=rts, y=patt, weight.fun=log_fun, breaks=time_interval, - filepath="~/test_twdtw", overwrite=TRUE, format="GTiff", mc.cores=3, - chunk.size=1000) - -plot(r_twdtw, type="distance") - -r_lucc = twdtwClassify(r_twdtw, format="GTiff", overwrite=TRUE) - -plot(r_lucc) - -plot(r_lucc, type="distance") - -} -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\references{ -[1] Maus V, Camara G, Cartaxo R, Sanchez A, Ramos FM, de Queiroz, GR. -(2016). A Time-Weighted Dynamic Time Warping method for land use and land cover -mapping. Selected Topics in Applied Earth Observations and Remote Sensing, -IEEE Journal of, vol.PP, no.99, pp.1-11. - -[2] Giorgino, T. (2009). Computing and Visualizing Dynamic Time Warping Alignments in R: -The dtw Package. Journal of Statistical Software, 31, 1-24. - -[3] Muller, M. (2007). Dynamic Time Warping. In Information Retrieval for Music -and Motion (pp. 79-84). London: Springer London, Limited. -} -\seealso{ -\code{\link[dtwSat]{twdtwMatches-class}}, -\code{\link[dtwSat]{twdtwTimeSeries-class}}, -\code{\link[dtwSat]{twdtwRaster-class}}, -\code{\link[dtwSat]{getTimeSeries}}, and -\code{\link[dtwSat]{createPatterns}} -} - diff --git a/man/twdtwAssessment-class.Rd b/man/twdtwAssessment-class.Rd deleted file mode 100644 index ca28222..0000000 --- a/man/twdtwAssessment-class.Rd +++ /dev/null @@ -1,115 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/class-twdtwAccuracy.R, R/twdtwAssessment.R -\docType{methods} -\name{twdtwAssessment-class} -\alias{twdtwAssess} -\alias{twdtwAssess,twdtwRaster-method} -\alias{twdtwAssessment} -\alias{twdtwAssessment-class} -\title{class "twdtwAssessment"} -\usage{ -\S4method{twdtwAssess}{twdtwRaster}(object, y, labels = NULL, - id.labels = NULL, proj4string = NULL, conf.int = 0.95) -} -\arguments{ -\item{object}{an object of class \code{\link[dtwSat]{twdtwRaster}} resulting from -the classification, i.e. \code{\link[dtwSat]{twdtwClassify}}.} - -\item{y}{a \code{\link[base]{data.frame}} whose attributes are: longitude, -latitude, the start ''from'' and the end ''to'' of the time interval -for each sample. This can also be a \code{\link[sp]{SpatialPointsDataFrame}} -whose attributes are the start ''from'' and the end ''to'' of the time interval. -If missing ''from'' and/or ''to'', they are set to the time range of the -\code{object}.} - -\item{labels}{character vector with time series labels. For signature -\code{\link[dtwSat]{twdtwRaster}} this argument can be used to set the -labels for each sample in \code{y}, or it can be combined with \code{id.labels} -to select samples with a specific label.} - -\item{id.labels}{a numeric or character with an column name from \code{y} to -be used as samples labels. Optional.} - -\item{proj4string}{projection string, see \code{\link[sp]{CRS-class}}. Used -if \code{y} is a \code{\link[base]{data.frame}}.} - -\item{conf.int}{specifies the confidence level (0-1).} -} -\description{ -This class stores the map assessment. -} -\section{Methods (by generic)}{ -\itemize{ -\item \code{twdtwAssess}: this function performs an accuracy assessment -of the classified maps. The function returns Overall Accuracy, -User's Accuracy, Produce's Accuracy, and error matrix (confusion matrix) for -each time interval and a summary considering all classified intervals. -}} -\section{Slots }{ - -\describe{ - \item{\code{accuracySummary}:}{Overall Accuracy, User's Accuracy, Produce's Accuracy, - and Error Matrix (confusion matrix) considering all time periods.} - \item{\code{accuracyByPeriod}:}{Overall Accuracy, User's Accuracy, Produce's Accuracy, - and Error Matrix (confusion matrix) for each time periods independently from each other.} - \item{\code{data}:}{A \code{\link[base]{data.frame}} with period (from - to), reference labels, - predicted labels, and other TWDTW information.} -} -} -\examples{ -\dontrun{ - -} -\dontrun{ - -# 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 fiels 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, filepath="res1") -plot(r_lucc) - -# Assess classification -twdtw_assess = twdtwAssess(r_lucc, validation_samples, proj4string=proj_str) -twdtw_assess@data - -} -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwRaster-class}}, and -\code{\link[dtwSat]{twdtwClassify}}. -} - diff --git a/man/twdtwClassify.Rd b/man/twdtwClassify.Rd deleted file mode 100644 index a4968e3..0000000 --- a/man/twdtwClassify.Rd +++ /dev/null @@ -1,111 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/twdtwClassify.R -\docType{methods} -\name{twdtwClassify} -\alias{twdtwClassify} -\alias{twdtwClassify,twdtwMatches-method} -\alias{twdtwClassify,twdtwRaster-method} -\alias{twdtwClassify-twdtwRaster} -\alias{twdtwClassify-twdtwTimeSeries} -\title{Classify time series} -\usage{ -twdtwClassify(x, ...) - -\S4method{twdtwClassify}{twdtwMatches}(x, patterns.labels = NULL, - from = NULL, to = NULL, by = NULL, breaks = NULL, overlap = 0.5, - thresholds = Inf, fill = "unclassified") - -\S4method{twdtwClassify}{twdtwRaster}(x, patterns.labels = NULL, - thresholds = Inf, fill = 255, filepath, ...) -} -\arguments{ -\item{x}{an object of class twdtw*. This is the target time series. -Usually, it is a set of unclassified time series.} - -\item{...}{arguments to pass to specifique methods for each twdtw* signature -and other arguments to pass to \code{\link[raster]{writeRaster}}.} - -\item{patterns.labels}{a vector with labels of the patterns.} - -\item{from}{A character or \code{\link[base]{Dates}} object in the format "yyyy-mm-dd".} - -\item{to}{A \code{\link[base]{character}} or \code{\link[base]{Dates}} object in the format "yyyy-mm-dd".} - -\item{by}{A \code{\link[base]{character}} with the intevals size, \emph{e.g.} "6 month".} - -\item{breaks}{A vector of class \code{\link[base]{Dates}}. This replaces the arguments \code{from}, -\code{to}, and \code{by}.} - -\item{overlap}{A number between 0 and 1. The minimum overlapping -between one match and the interval of classification. Default is 0.5, -\emph{i.e.} an overlap minimum of 50\%.} - -\item{thresholds}{A numeric vector the same length as \code{patterns.labels}. -The TWDTW dissimilarity thresholds, i.e. the maximum TWDTW cost for consideration -in the classification. Default is \code{Inf} for all \code{patterns.labels}.} - -\item{fill}{a character or value to fill the classification gaps. -For signature \code{twdtwTimeSeries} the default is \code{fill="unclassified"}, and -for signature \code{twdtwRaster} the default is \code{fill="unclassified"}.} - -\item{filepath}{A character. The path to save the raster with results. If not informed the -function saves in the same directory as the input time series raster.} -} -\value{ -An object of class twdtw*. -} -\description{ -This function classifies the intervals of a time series -based on the TWDTW results. -} -\examples{ -# Classifying time series based on TWDTW results -ts = twdtwTimeSeries(MOD13Q1.ts.list) -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -log_fun = logisticWeight(-0.1, 100) -time_intervals = seq(from=as.Date("2007-09-01"), to=as.Date("2013-09-01"), by="6 month") -mat = twdtwApply(x=ts, y=patt, weight.fun=log_fun, keep=TRUE) -best_mat = twdtwClassify(x=mat, breaks=time_intervals, overlap=0.5) -plot(x=best_mat, type="classification") - -\dontrun{ -require(parallel) -best_mat = mclapply(as.list(mat), mc.cores=2, FUN=twdtwClassify, breaks=time_intervals, overlap=0.5) -best_mat = twdtwMatches(alignments=best_mat) -} -\dontrun{ -# Run TWDTW analysis for raster time series -patt = MOD13Q1.MT.yearly.patterns -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) - -time_interval = seq(from=as.Date("2007-09-01"), to=as.Date("2013-09-01"), - by="12 month") -log_fun = weight.fun=logisticWeight(-0.1,50) - -r_twdtw = twdtwApply(x=rts, y=patt, weight.fun=log_fun, breaks=time_interval, - filepath="~/test_twdtw", overwrite=TRUE, format="GTiff", mc.cores=3) - -r_lucc = twdtwClassify(r_twdtw, format="GTiff") - -plotMaps(r_lucc) - -} -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwApply}}, -\code{\link[dtwSat]{twdtwMatches-class}}, -\code{\link[dtwSat]{twdtwTimeSeries-class}}, and -\code{\link[dtwSat]{twdtwRaster-class}}, -} - diff --git a/man/twdtwCrossValidation-class.Rd b/man/twdtwCrossValidation-class.Rd deleted file mode 100644 index 8ea19e0..0000000 --- a/man/twdtwCrossValidation-class.Rd +++ /dev/null @@ -1,101 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/class-crossValidation.R, R/methods.R, R/twdtwCrossValidation.R -\docType{methods} -\name{twdtwCrossValidation-class} -\alias{show,twdtwCrossValidation-method} -\alias{summary,twdtwCrossValidation-method} -\alias{twdtwCrossValidation} -\alias{twdtwCrossValidation,ANY-method} -\alias{twdtwCrossValidation-class} -\title{class "twdtwCrossValidation"} -\usage{ -\S4method{show}{twdtwCrossValidation}(object) - -\S4method{summary}{twdtwCrossValidation}(object, conf.int = 0.95, ...) - -\S4method{twdtwCrossValidation}{ANY}(object, times, p, ...) -} -\arguments{ -\item{object}{an object of class \code{\link[dtwSat]{twdtwTimeSeries}}.} - -\item{conf.int}{specifies the confidence level (0-1) for interval estimation of the -population mean. For more details see \code{\link[ggplot2]{mean_cl_boot}}.} - -\item{...}{Other arguments to be passed to \code{\link[dtwSat]{createPatterns}} and -to \code{\link[dtwSat]{twdtwApply}}.} - -\item{times}{Number of partitions to create.} - -\item{p}{the percentage of data that goes to training. -See \code{\link[caret]{createDataPartition}} for details.} -} -\description{ -This class stores the cross-validation. -} -\section{Methods (by generic)}{ -\itemize{ -\item \code{twdtwCrossValidation}: Splits the set of time -series into training and validation. The function uses stratified -sampling and a simple random sampling for each stratum. For each data partition -this function performs a TWDTW analysis and returns the Overall Accuracy, -User's Accuracy, Produce's Accuracy, error matrix (confusion matrix), and a -\code{\link[base]{data.frame}} with the classification (Predicted), the -reference classes (Reference), and some TWDTW information. -}} -\section{Slots }{ - -\describe{ - \item{\code{partitions}:}{A list with the indices of time series used for training.} - \item{\code{accuracy}:}{A list with the accuracy and other TWDTW information for each - data partitions.} -} -} -\examples{ -\dontrun{ - -} -\dontrun{ -# Data folder -data_folder = system.file("lucc_MT/data", package = "dtwSat") - -# Read dates -dates = scan(paste(data_folder,"timeline", sep = "/"), what = "dates") - -# Read raster time series -evi = brick(paste(data_folder,"evi.tif", sep = "/")) -raster_timeseries = twdtwRaster(evi, timeline = dates) - -# Read field samples -field_samples = read.csv(paste(data_folder,"samples.csv", sep = "/")) -table(field_samples[["label"]]) - -# Read field samples projection -proj_str = scan(paste(data_folder,"samples_projection", sep = "/"), - what = "character") - -# Get sample time series from raster time series -field_samples_ts = getTimeSeries(raster_timeseries, - y = field_samples, proj4string = proj_str) -field_samples_ts - -# Run cross validation -set.seed(1) -# Define TWDTW weight function -log_fun = logisticWeight(alpha=-0.1, beta=50) -cross_validation = twdtwCrossValidation(field_samples_ts, times=3, p=0.1, - freq = 8, formula = y ~ s(x, bs="cc"), weight.fun = log_fun) -cross_validation - -summary(cross_validation) - -} -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwMatches-class}}, -\code{\link[dtwSat]{createPatterns}}, and -\code{\link[dtwSat]{twdtwApply}}. -} - diff --git a/man/twdtwMatches-class.Rd b/man/twdtwMatches-class.Rd deleted file mode 100644 index ef30dd8..0000000 --- a/man/twdtwMatches-class.Rd +++ /dev/null @@ -1,128 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/class-twdtwMatches.R, R/methods.R -\docType{methods} -\name{twdtwMatches-class} -\alias{[,twdtwMatches,ANY,ANY,ANY-method} -\alias{[[,twdtwMatches,numeric,ANY-method} -\alias{as.list,twdtwMatches-method} -\alias{as.list,twdtwRaster-method} -\alias{index,twdtwMatches-method} -\alias{is.twdtwMatches} -\alias{is.twdtwMatches,ANY-method} -\alias{labels,twdtwMatches-method} -\alias{length,twdtwMatches-method} -\alias{show,twdtwMatches-method} -\alias{twdtwMatches} -\alias{twdtwMatches,ANY-method} -\alias{twdtwMatches-class} -\alias{twdtwMatches-create} -\title{class "twdtwMatches"} -\usage{ -\S4method{twdtwMatches}{ANY}(timeseries = NULL, patterns = NULL, - alignments = NULL) - -\S4method{index}{twdtwMatches}(x) - -\S4method{length}{twdtwMatches}(x) - -\S4method{as.list}{twdtwMatches}(x) - -\S4method{as.list}{twdtwRaster}(x) - -\S4method{[}{twdtwMatches,ANY,ANY,ANY}(x, i, j, drop = TRUE) - -\S4method{[[}{twdtwMatches,numeric,ANY}(x, i, j, drop = TRUE) - -\S4method{labels}{twdtwMatches}(object) - -\S4method{show}{twdtwMatches}(object) - -\S4method{is.twdtwMatches}{ANY}(x) -} -\arguments{ -\item{timeseries}{a \code{\link[dtwSat]{twdtwTimeSeries}} object.} - -\item{patterns}{a \code{\link[dtwSat]{twdtwTimeSeries}} object.} - -\item{alignments}{an object of class list with the TWDTW results with -the same length as \code{timeseries} or a list of twdtwMatches.} - -\item{x}{an object of class twdtwMatches.} - -\item{i}{indices of the time series.} - -\item{j}{indices of the pattern.} - -\item{drop}{if TRUE returns a data.frame, if FALSE returns a list. -Default is TRUE.} - -\item{object}{an object of class twdtwMatches.} - -\item{labels}{a vector with labels of the time series.} - -\item{...}{objects of class twdtwMatches.} -} -\description{ -Class for Time-Weighted Dynamic Time Warping results. -} -\section{Methods (by generic)}{ -\itemize{ -\item \code{twdtwMatches}: Create object of class twdtwMatches. - -\item \code{is.twdtwMatches}: Check if the object belongs to the class twdtwMatches. -}} -\section{Slots }{ - -\describe{ - \item{\code{timeseries}:}{An object of class \code{\link[dtwSat]{twdtwTimeSeries-class}} with the satellite time series.} - \item{\code{pattern}:}{An object of class \code{\link[dtwSat]{twdtwTimeSeries-class}} with the temporal patterns.} - \item{\code{alignments}:}{A \code{\link[base]{list}} of TWDTW results with the same length as - the \code{timeseries}. Each element in this list has the following results for each temporal pattern - in \code{patterns}: - \cr\code{from}: a vector with the starting dates of each match in the format "YYYY-MM-DD", - \cr\code{to}: a vector with the ending dates of each match in the format "YYYY-MM-DD", - \cr\code{distance}: a vector with TWDTW dissimilarity measure, and - \cr\code{K}: the number of matches of the pattern. - } - \item{This list might have additional elements:}{ if \code{keep=TRUE} in the \code{twdtwApply} call - the list is extended to include internal structures used during the TWDTW computation: - \cr\code{costMatrix}: cumulative cost matrix, - \cr\code{directionMatrix}: directions of steps that would be taken from each element of matrix, - \cr\code{startingMatrix}: the starting points of each element of the matrix, - \cr\code{stepPattern}: \code{\link[dtw]{stepPattern}} used for the - computation, see package \code{\link[dtw]{dtw}}, - \cr\code{N}: the length of the \code{pattern}, - \cr\code{M}: the length of the time series \code{timeseries}, - \cr\code{timeWeight}: time weight matrix, - \cr\code{localMatrix}: local cost matrix, - \cr\code{matching}: A list whose elements have the matching points for - each match between pattern the time series, such that: - \cr--\code{index1}: a vector with matching points of the pattern, and - \cr--\code{index2}: a vector with matching points of the time series. - } -} -} -\examples{ -ts = twdtwTimeSeries(timeseries=MOD13Q1.ts.list) -patterns = twdtwTimeSeries(timeseries=MOD13Q1.patterns.list) -matches = twdtwApply(x = ts, y = patterns) -class(matches) -length(matches) -matches -# Creating objects of class twdtwMatches -ts = twdtwTimeSeries(MOD13Q1.ts.list) -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -mat = twdtwApply(ts, patt, weight.fun = logisticWeight(-0.1, 100)) -mat = twdtwMatches(ts, patterns=patt, alignments=mat) -mat - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwApply}}, -\code{\link[dtwSat]{twdtwTimeSeries-class}}, and -\code{\link[dtwSat]{twdtwRaster-class}} -} - diff --git a/man/twdtwRaster-class.Rd b/man/twdtwRaster-class.Rd deleted file mode 100644 index a9ea91f..0000000 --- a/man/twdtwRaster-class.Rd +++ /dev/null @@ -1,176 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/class-twdtwRaster.R, R/methods.R -\docType{methods} -\name{twdtwRaster-class} -\alias{[,twdtwRaster,ANY,ANY,ANY-method} -\alias{[[,twdtwRaster,ANY,ANY-method} -\alias{bands} -\alias{bands,twdtwRaster-method} -\alias{coverages} -\alias{coverages,twdtwRaster-method} -\alias{crop,twdtwRaster-method} -\alias{dim,twdtwRaster-method} -\alias{extent,twdtwRaster-method} -\alias{index,twdtwRaster-method} -\alias{is.twdtwRaster} -\alias{is.twdtwRaster,ANY-method} -\alias{labels,twdtwRaster-method} -\alias{layers} -\alias{layers,twdtwRaster-method} -\alias{length,twdtwRaster-method} -\alias{levels,twdtwRaster-method} -\alias{names,twdtwRaster-method} -\alias{ncol,twdtwRaster-method} -\alias{nlayers,twdtwRaster-method} -\alias{nrow,twdtwRaster-method} -\alias{projection,twdtwRaster-method} -\alias{res,twdtwRaster-method} -\alias{show,twdtwRaster-method} -\alias{twdtwRaster} -\alias{twdtwRaster,ANY-method} -\alias{twdtwRaster-class} -\alias{twdtwRaster-create} -\title{class "twdtwRaster"} -\usage{ -\S4method{twdtwRaster}{ANY}(..., timeline, doy = NULL, layers = NULL, - labels = NULL, levels = NULL, filepath = NULL) - -\S4method{dim}{twdtwRaster}(x) - -\S4method{res}{twdtwRaster}(x) - -\S4method{extent}{twdtwRaster}(x, y, ...) - -\S4method{projection}{twdtwRaster}(x) - -\S4method{ncol}{twdtwRaster}(x) - -\S4method{nrow}{twdtwRaster}(x) - -\S4method{nlayers}{twdtwRaster}(x) - -\S4method{levels}{twdtwRaster}(x) - -\S4method{layers}{twdtwRaster}(x) - -\S4method{coverages}{twdtwRaster}(x) - -\S4method{bands}{twdtwRaster}(x) - -\S4method{names}{twdtwRaster}(x) - -\S4method{index}{twdtwRaster}(x) - -\S4method{length}{twdtwRaster}(x) - -\S4method{[}{twdtwRaster,ANY,ANY,ANY}(x, i) - -\S4method{[[}{twdtwRaster,ANY,ANY}(x, i) - -\S4method{labels}{twdtwRaster}(object) - -\S4method{crop}{twdtwRaster}(x, y, ...) - -\S4method{extent}{twdtwRaster}(x, y, ...) - -\S4method{show}{twdtwRaster}(object) - -\S4method{is.twdtwRaster}{ANY}(x) -} -\arguments{ -\item{...}{objects of class \code{\link[raster]{RasterBrick-class}} or -\code{\link[raster]{RasterStack-class}}.} - -\item{timeline}{a vector with the dates of the satellite images -in the format of "YYYY-MM-DD".} - -\item{doy}{A \code{\link[raster]{RasterBrick-class}} or -\code{\link[raster]{RasterStack-class}} with a sequence of days of the year for each pixel. -\code{doy} must have the same spatial and temporal extents as the Raster* objects passed to \code{...}. -If \code{doy} is not informed then at least one Raster* object must be passed through \code{...}.} - -\item{layers}{a vector with the names of the \code{Raster*} objects -passed to "\code{...}". If not informed the layers are set to the -names of objects in "\code{...}".} - -\item{labels}{a vector of class \code{\link[base]{character}} with -labels of the values in the Raster* objects. This is -useful for categorical Raster* values of land use classes.} - -\item{levels}{a vector of class \code{\link[base]{numeric}} with -levels of the values in the Raster* objects. This is -useful for categorical Raster* values of land use classes.} - -\item{filepath}{A character. The path to save the raster time series. If informed the -function saves a raster file for each Raster* object in the list, \emph{i.e} one file -for each time series. This way the function retrieves an list of -\code{\link[raster]{RasterBrick-class}}. It is useful when the time series are -originally stores in separated files. See details.} - -\item{x}{an object of class twdtwRaster.} - -\item{y}{Extent object, or any object from which an Extent object can be extracted.} - -\item{i}{indices of the time series.} - -\item{object}{an object of class twdtwRaster.} -} -\description{ -Class for set of satellite time series. -} -\details{ -The performance the functions \code{\link[dtwSat]{twdtwApply}} and -\code{\link[dtwSat]{getTimeSeries}} is improved if the Raster* objects are connected -to files with the whole time series for each attribute. -} -\section{Methods (by generic)}{ -\itemize{ -\item \code{twdtwRaster}: Create object of class twdtwRaster. - -\item \code{is.twdtwRaster}: Check if the object belongs to the class twdtwRaster. -}} -\section{Slots }{ - -\describe{ - \item{\code{timeseries}:}{A list of multi-layers Raster* objects - with the satellite image time series.} - \item{\code{timeline}:}{A vector of class \code{\link[base]{date}} - with dates of the satellite images in \code{timeseries}.} - \item{\code{layers}:}{A vector of class \code{\link[base]{character}} - with the names of the Raster* objects.} - \item{\code{labels}:}{A vector of class \code{\link[base]{factor}} - with levels and labels of the values in the Raster* objects. This - is useful for categorical Raster* values of land use classes.} -} -} -\examples{ -# Creating new object of class twdtwTimeSeries -evi = brick(system.file("lucc_MT/data/evi.tif", package="dtwSat")) -timeline = scan(system.file("lucc_MT/data/timeline", package="dtwSat"), what="date") -rts = new("twdtwRaster", timeseries = evi, timeline = timeline) - -\dontrun{ -# Creating objects of class twdtwRaster -evi = brick(system.file("lucc_MT/data/evi.tif", package="dtwSat")) -timeline = scan(system.file("lucc_MT/data/timeline", package="dtwSat"), what="date") -ts_evi = twdtwRaster(evi, timeline=timeline) - -ndvi = brick(system.file("lucc_MT/data/ndvi.tif", package="dtwSat")) -blue = brick(system.file("lucc_MT/data/blue.tif", package="dtwSat")) -red = brick(system.file("lucc_MT/data/red.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")) -rts = twdtwRaster(evi, ndvi, blue, red, nir, mir, timeline=timeline, doy=doy) -} -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwApply}}, -\code{\link[dtwSat]{getTimeSeries}}, -\code{\link[dtwSat]{twdtwMatches-class}}, and -\code{\link[dtwSat]{twdtwTimeSeries-class}} -} - diff --git a/man/twdtwTimeSeries-class.Rd b/man/twdtwTimeSeries-class.Rd deleted file mode 100644 index f881985..0000000 --- a/man/twdtwTimeSeries-class.Rd +++ /dev/null @@ -1,113 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/class-twdtwTimeSeries.R, R/methods.R -\docType{methods} -\name{twdtwTimeSeries-class} -\alias{[,twdtwTimeSeries,ANY,ANY,ANY-method} -\alias{[[,twdtwTimeSeries,ANY,ANY-method} -\alias{as.list,twdtwTimeSeries-method} -\alias{dim,twdtwTimeSeries-method} -\alias{index,twdtwTimeSeries-method} -\alias{is.twdtwTimeSeries} -\alias{is.twdtwTimeSeries,ANY-method} -\alias{labels,twdtwTimeSeries-method} -\alias{length,twdtwTimeSeries-method} -\alias{levels,twdtwTimeSeries-method} -\alias{ncol,twdtwTimeSeries-method} -\alias{nrow,twdtwTimeSeries-method} -\alias{show,twdtwTimeSeries-method} -\alias{twdtwTimeSeries} -\alias{twdtwTimeSeries,ANY-method} -\alias{twdtwTimeSeries-class} -\alias{twdtwTimeSeries-create} -\title{class "twdtwTimeSeries"} -\usage{ -\S4method{twdtwTimeSeries}{ANY}(..., labels = NULL) - -\S4method{dim}{twdtwTimeSeries}(x) - -\S4method{index}{twdtwTimeSeries}(x) - -\S4method{nrow}{twdtwTimeSeries}(x) - -\S4method{ncol}{twdtwTimeSeries}(x) - -\S4method{length}{twdtwTimeSeries}(x) - -\S4method{as.list}{twdtwTimeSeries}(x) - -\S4method{[}{twdtwTimeSeries,ANY,ANY,ANY}(x, i) - -\S4method{[[}{twdtwTimeSeries,ANY,ANY}(x, i) - -\S4method{labels}{twdtwTimeSeries}(object) - -\S4method{levels}{twdtwTimeSeries}(x) - -\S4method{show}{twdtwTimeSeries}(object) - -\S4method{is.twdtwTimeSeries}{ANY}(x) -} -\arguments{ -\item{...}{\code{\link[dtwSat]{twdtwTimeSeries}} objects, -\code{\link[zoo]{zoo}} objects or a list of \code{\link[zoo]{zoo}} objects.} - -\item{labels}{a vector with labels of the time series.} - -\item{x}{an object of class twdtwTimeSeries.} - -\item{i}{indices of the time series.} - -\item{object}{an object of class twdtwTimeSeries.} -} -\description{ -Class for set of irregular time series. -} -\section{Methods (by generic)}{ -\itemize{ -\item \code{twdtwTimeSeries}: Create object of class twdtwTimeSeries. - -\item \code{is.twdtwTimeSeries}: Check if the object belongs to the class twdtwTimeSeries. -}} -\section{Slots }{ - -\describe{ - \item{\code{timeseries}:}{A list of \code{\link[zoo]{zoo}} objects.} - \item{\code{labels}:}{A vector of class \code{\link[base]{factor}} with time series labels.} -} -} -\examples{ -# Creating new object of class twdtwTimeSeries -ptt = new("twdtwTimeSeries", timeseries = MOD13Q1.patterns.list, - labels = names(MOD13Q1.patterns.list)) -class(ptt) -labels(ptt) -levels(ptt) -length(ptt) -nrow(ptt) -ncol(ptt) -dim(ptt) -# Creating objects of class twdtwTimeSeries from zoo objects -ts = twdtwTimeSeries(MOD13Q1.ts) -ts - -# Creating objects of class twdtwTimeSeries from list of zoo objects -patt = twdtwTimeSeries(MOD13Q1.patterns.list) -patt - -# Joining objects of class twdtwTimeSeries -tsA = twdtwTimeSeries(MOD13Q1.ts.list[[1]], labels = "A") -tsB = twdtwTimeSeries(B = MOD13Q1.ts.list[[2]]) -ts = twdtwTimeSeries(tsA, tsB, C=MOD13Q1.ts) -ts - -} -\author{ -Victor Maus, \email{vwmaus1@gmail.com} -} -\seealso{ -\code{\link[dtwSat]{twdtwMatches-class}}, -\code{\link[dtwSat]{twdtwRaster-class}}, -\code{\link[dtwSat]{getTimeSeries}}, and -\code{\link[dtwSat]{twdtwApply}} -} -