Skip to content

Commit

Permalink
Include writeRaster for twdtwRaster class
Browse files Browse the repository at this point in the history
  • Loading branch information
vwmaus committed Jun 5, 2017
1 parent 63f6a4a commit 886f1b4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ exportMethods(twdtwMatches)
exportMethods(twdtwRaster)
exportMethods(twdtwTimeSeries)
exportMethods(twdtwXtable)
exportMethods(writeRaster)
import(ggplot2)
import(methods)
import(raster)
Expand Down
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

Include the function twdtwApplyParallel for TWDTW parallel processing using the package snow

Include writeRaster for twdtwRaster class

Improve tests and documentation

* Fixing bugs

Improve memory usage of twdtwApply

Improve memory usage and speed of twdtwClassify

* Fixing bugs

Fix bug in twdtwAssess for class twdtwMatches

Fix bug in twdtwRaster
Expand Down
13 changes: 13 additions & 0 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ extent.twdtwRaster = function(x){
extent(x@timeseries[[1]])
}

writeRaster.twdtwRaster = function(x, filepath, ...){
lapply(names(x@timeseries), function(i) writeRaster(x@timeseries[[i]], filename = paste0(filepath, "/", i, ".grd"), ...))
}

projection.twdtwRaster = function(x){
projection(x@timeseries[[1]])
}
Expand Down Expand Up @@ -163,6 +167,15 @@ setMethod(f = "res", "twdtwRaster",
setMethod(f = "extent", "twdtwRaster",
definition = extent.twdtwRaster)

#' @inheritParams twdtwRaster-class
#' @rdname twdtwRaster-class
#' @export
setMethod("writeRaster", "twdtwRaster",
definition = function(x, filepath = ".", ...) {
writeRaster.twdtwRaster(x, filepath, ...)
}
)

#' @inheritParams twdtwRaster-class
#' @rdname twdtwRaster-class
#' @export
Expand Down
3 changes: 3 additions & 0 deletions man/twdtwRaster-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 886f1b4

Please sign in to comment.