[R] Subset Rasterbrick by time
Miluji Sb
miluji@b @ending from gm@il@com
Mon Jun 18 16:21:50 CEST 2018
Dear all,
I have a rasterbrick with the date/time information provided which I would
like to subset by year.
However, when I use the following code for sub-setting;
new_brick <- subset(original, which(getZ( original ) >= as.Date("2000-01-01
10:30:00") & getZ(original ) <= as.Date("2014-12-31 10:30:00")))
The date/time information seems to be lost.
Furthermore, the class of the date/time seems to be character;
##
class(getZ( original ))
[1] "character"
Is it possible to convert this string to date before sub-setting or retain
the date/time information after sub-setting?
### original RasterBrick ###
class : RasterBrick
dimensions : 600, 1440, 864000, 11320 (nrow, ncol, ncell, nlayers)
resolution : 0.25, 0.25 (x, y)
extent : -180, 180, -60, 90 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source :
/work/mm01117/GLDAS_025_deg/daily/gldas_tavg_tmin_tmax_precip_windspd_sphum_daily_1986_2016.nc4
names : X1986.01.01.10.30.00, X1986.01.02.10.30.00,
X1986.01.03.10.30.00, X1986.01.04.10.30.00, X1986.01.05.10.30.00,
X1986.01.06.10.30.00, X1986.01.07.10.30.00, X1986.01.08.10.30.00,
X1986.01.09.10.30.00, X1986.01.10.10.30.00, X1986.01.11.10.30.00,
X1986.01.12.10.30.00, X1986.01.13.10.30.00, X1986.01.14.10.30.00,
X1986.01.15.10.30.00, ...
Date/time : 1986-01-01 10:30:00, 2016-12-31 10:30:00 (min, max)
varname : v1
### new RasterBrick ###
class : RasterStack
dimensions : 600, 1440, 864000, 5477 (nrow, ncol, ncell, nlayers)
resolution : 0.25, 0.25 (x, y)
extent : -180, 180, -60, 90 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
names : X2000.01.01.10.30.00, X2000.01.02.10.30.00,
X2000.01.03.10.30.00, X2000.01.04.10.30.00, X2000.01.05.10.30.00,
X2000.01.06.10.30.00, X2000.01.07.10.30.00, X2000.01.08.10.30.00,
X2000.01.09.10.30.00, X2000.01.10.10.30.00, X2000.01.11.10.30.00,
X2000.01.12.10.30.00, X2000.01.13.10.30.00, X2000.01.14.10.30.00,
X2000.01.15.10.30.00, ...
Any help will be greatly appreciated.
Sincerely,
Milu
[[alternative HTML version deleted]]
More information about the R-help
mailing list