Skip to content

Commit

Permalink
updated write.tgrass, after change in raster
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Oct 27, 2015
1 parent b6bb80c commit 236a3b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/tgrass.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ read.tgrass = function(fname, localName = TRUE, useTempDir = TRUE, isGeoTiff = T

write.tgrass = function(obj, fname, ...) {
# require(raster)
if (!requireNamespace("raster", quietly = TRUE))
stop("package raster required for write.tgrass")
if (is(obj, "STFDF")) {
end.time = obj@endTime
obj = as(obj, "RasterStack")
#obj = as(obj, "RasterStack")
obj = as(obj, "RasterBrick")
} else
end.time = NULL
n = paste(names(obj), ".tif", sep = "")
olddir = getwd()
dir = tempdir() # gets the same as read.tgrass got!
setwd(dir)
# write .tifs:
if (!requireNamespace("raster", quietly = TRUE))
stop("package raster required for write.tgrass")
for (i in 1:(raster::nlayers(obj)))
raster::writeRaster(raster::raster(obj, layer=i), n[i], ...)
# write proj.txt:
Expand Down
4 changes: 4 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ subsetting STF, STS, STI with [
kriging without STFDF's, kriging with STIDF's (I think this is supported now)

single location prediction.

Sat Oct 17 22:40:29 CEST 2015
Meng: coerce STIDF -> STFDF: do NOT set endTime to full interval?
alternative: (a) zero interval width, (b) mean of endTime of each time slice?

0 comments on commit 236a3b3

Please sign in to comment.