[R-sig-Geo] write.tgrass (spacetime) does not work for any RasterStack

Veronica Andreo veroandreo at gmail.com
Tue Sep 6 20:43:54 CEST 2016


Hello

I'm working with raster time series in GRASS, but I needed to apply a
gap-filling function available in R (dineof in the package sinkr).
Exporting the time series from GRASS and importing into R went fine... I
did all the processing which implies transforming the raster time series
into a matrix, run dineof and then rebuild the RasterStack... And here is
the problem... write.tgrass does not work with this rebuilt RasterStack

I get this error:

write.tgrass(tempmean_new_rs, "tempmean_new_from_R.tar.gzip")
Error in data.frame(names(obj), start.time, end.time) : arguments imply
differing number of rows: 156, 0

write.tgrass does work however with the RasterStack imported and read with
read.tgrass. So, I compared both RasterStacks:

### the one imported from GRASS (without any change):
> test
class       : RasterStack
dimensions  : 104, 139, 14456, 156  (nrow, ncol, ncell, nlayers)
resolution  : 500, 500  (x, y)
extent      : 624500, 694000, 208500, 260500  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +to_meter=1
names       : X2000_01_tempmean, X2000_02_tempmean, X2000_03_tempmean,
X2000_04_tempmean, X2000_05_tempmean, X2000_06_tempmean, X2000_07_tempmean,
X2000_08_tempmean, X2000_09_tempmean, X2000_10_tempmean, X2000_11_tempmean,
X2000_12_tempmean, X2001_01_tempmean, X2001_02_tempmean, X2001_03_tempmean,
...
time        : 2000-01-01 - 2012-12-01 (range)

### the one I re-constructed after doing my processing
> tempmean_new_rs
class       : RasterStack
dimensions  : 104, 139, 14456, 156  (nrow, ncol, ncell, nlayers)
resolution  : 500, 500  (x, y)
extent      : 624500, 694000, 208500, 260500  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +to_meter=1
names       :    layer.1,    layer.2,    layer.3,    layer.4,    layer.5,
 layer.6,    layer.7,    layer.8,    layer.9,   layer.10,   layer.11,
layer.12,   layer.13,   layer.14,   layer.15, ...
min values  :  2.8337839,  6.4129490, 11.2577566, 13.2967885, 20.4898198,
24.3399993, 24.2426851, 24.0908008, 20.4639886, 14.9326849,  7.8406800,
 0.6784587,  3.0555789,  6.4902200,  7.4145889, ...
max values  :   4.496206,   8.090485,  12.699460,  14.956419,  21.605554,
 25.174480,  25.044242,  24.839163,  21.734339,  16.165316,   9.309428,
2.563087,   4.884175,   8.479331,   9.218642, ...

All the same, *except for the time attribute* that the one read from GRASS
has and the one I rebuilt doesn't. Maybe there's the problem? How do I add
this time attribute to my RasterStack so that write.tgrass creates the
 file I need to import directly into GRASS as a raster time series???

Thanks a lot for any hint!

Best,
Vero

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list